# Coding the AI

The AI uses the java services architecture for the bundled AIs as well as to allow for additional AIs.

You can add an additional AIs by adding to the file:

>     META-INF/services/net.yura.domination.engine.ai.AIManager

Inside the main jar file or creating a new jar with a file in the same location that contains a list of classes, one on each line

>     net.yura.domination.engine.ai.AISubmissive
>     net.yura.domination.engine.ai.AIEasy
>     net.yura.domination.engine.ai.AIAverage
>     net.yura.domination.engine.ai.AIHard
>     net.yura.domination.engine.ai.AITest

Each of the classes need to implement the AI interface

Each AI needs to have a unique id. It can be any positive integer that does not clash with existing ids, it is returned by this method:

>     int getType();

Each AI also has a unique String, this is used for selecting the AI and should also not clash with any existing AIs and not contain any spaces (e.g. aggressive)

>     String getCommand();

Here are the existing types and commands that come with the game:

>     class
>     type
>     command

>     reserved for human players
>     0

>     AISubmissive
>     3
>     crap

>     AIEasy
>     1
>     easy

>     AIAverage
>     4
>     average

>     AIHard
>     2
>     hard

>     AITest
>     5
>     test

Before each turn of the AI this method is called in order to give the current game object to the AI.

>     void setGame(RiskGame game);

These are the methods that are called depending on the current state of the game, they all return a String that is the command which is passed back to the game.

>     String getBattleWon();
>     String getTacMove();
>     String getTrade();
>     String getPlaceArmies();
>     String getAttack();
>     String getRoll();
>     String getCapital();
>     String getAutoDefendString();

The list of commands can be found in here
If you do not want to implement all the methods right away you can start by extending AISubmissive. This class follows all the rules of the game but does not attack.
Send me anything interesting you get working: yura@yura.net