Package net.sf.freecol.server.ai

FreeCol Artifical Intelligence

The main package of the Artifical Intelligence (AI) package tree.

AIMain has the responsibility of creating and managing AI-objects. Each instance of AIObject stores AI-specific information relating to a single FreeColGameObject. For example: AIUnit contains information about a single unit and has the methods the AI needs for controlling this unit.

Communication with the server

The server uses a Connection when communicating with the clients. The subclass DummyConnection is used for the computer controlled players, in order to avoid unnecessary network traffic. AIInGameInputHandler handles the messages received on the DummyConnection and calls the appropriate methods in AIPlayer. An example: the method AIPlayer.startWorking() gets invoked when it is the AI-player's turn.

The AI package is a part of the server so the server model is used by the computer players. We have defined the following interface for getting/modifying data within the model:

  • The AI may access information in the model directly.
  • Any changes to the model should be done by sending a network message through the "DummyConnection" the computer player is using. The reason for not changing the model directly, is that the server's control code has the responsibility of updating the clients when a change occurs.

This interface is a bit confusing and will probably be changed in the future (possibly by supporting direct manipulation of the model from the ai-code).