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:
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 lineMETA-INF/services/net.yura.domination.engine.ai.AIManager
Each of the classes need to implement the AI interfacenet.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 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:
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)int getType();
Here are the existing types and commands that come with the game:String getCommand();
Before each turn of the AI this method is called in order to give the current game object to the AI.
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.void setGame(RiskGame game);
The list of commands can be found in hereString getBattleWon(); String getTacMove(); String getTrade(); String getPlaceArmies(); String getAttack(); String getRoll(); String getCapital(); String getAutoDefendString();
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: email@example.com
copyright 2003-2013 yura.net