This article is specific to the AI Agent track competitions and will detail all the specifics that users will require to start implementing their own AI Agent algorithms for the Geometry Friends competition.
The Abstract Agent
First and foremost all agents must override the specific Circle or Rectangle Agent abstract classes, which will serve as the skeleton code and define key methods required for the interaction between the agents in the Geometry Friends game.
These methods include:
string AgentName() – The name of the agent. If both agents are implemented the name will be the conjunction of both agents.
bool ImplementedAgent() – A simple flag which tells the game if the agent is ready to be used or not. This should return true when running the agent;
bool HasAgentGivenUp() – A simple flag which tells the game if the agent has given up on the current level and the level simulation can terminate now;
void Setup(CountInformation nI, RectangleRepresentation sI, CircleRepresentation cI, ObstacleRepresentation oI, ObstacleRepresentation rPI, ObstacleRepresentation cPI, CollectibleRepresentation colI, Rectangle area, double timeLimit) – The Agent Setup method, which will be called by the game. For more information on the parameters please refer to the Knowing the Sensor Array article;
int GetAction() – The Agent action method, where users can return the action code which lets their agent perform an atomic action (e.g. Moving left or right, jump / morph). For a detailed list of all action codes please refer to the Agent Actions article.
void SensorsUpdated(int nC, RectangleRepresentation rI, CircleRepresentation cI, CollectibleRepresentation colI) – The agent sensor update method. This method is called by the game every few clicks with updated sensor information, allowing user created agents to update their own game state functions. For more information on these parameters and the sensor array please refer to the Knowing the Sensor Array article;
void Update(TimeSpan elapsedGameTime) – The current game elapsed time method. This method will be called constantly by the game so that agents can keep track of the elapsed time since the level was started.
Tips on Implementing your Agents
Users are expected and encouraged to use as many classes and methods as they want to support their AI algorithms and implementations. However, user’s should keep in mind all of the previous methods noted above as they are key instruments for running agents within the game.
We suggest that all users try out the game before heading straight into the AI implementation process. Getting to know the game and learning its key mechanics can provide invaluable insight. Exploiting both game characters to solve difficult level sections is an example.
When starting implementation, we suggest users start slowly, experiment with the GetAction method and learn the intricacies of both characters. We also strongly suggest taking a look at our Circle Code and Rectangle Code examples, which are very simple agent implementations. These two examples are already provided with the framework. We suggest you alter these or just replace them with your own implementations.
When developing an agent you developers are bound to require debugging information regarding the agent’s behavior. Beyond the typical console debugging (see for example the complete source code of the example random circle agent) and the Agent Logger tool developers can now use visual debugging. For an example on how to use this feature see Agent with Prediction & Visual Debug. Remember that to see this visual debug information you have to press the F1 key during the game.
A final note on console debugging of the agents: it is highly recommended that you use the GeometryFriends.Log class to log for your agent (introduced since version V41). By using this you re-use the framework’s logging system and can take advantage of logging to file behaviour already available. For example, when performing multiple simulations using the –log-to-file flag or using the batch simulator with this option selected. An additional reason to centralize the debugging here is that if an agent gives any type of error during its execution that error is shown in this log which can be found in the Log.txt file under the Logs directory of the game.