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 line
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:


Change Log svn


Screen Shots

Android App on Google Play

Android App on Amazon AppStore

FlashGUI Web Start
Launches Flash GUI Domination

SwingGUI Web Start
Launches Swing GUI Domination

Flash Applet
Swing Applet

Make Maps
Extra Maps
Make Translation
Make AI

Bug Tracker todo
Discussion Comments

Domination Project Page on SourceForge

Domination Project Page on Freshmeat R

Lobby Web Site on SourceForge

Lobby Project Page on SourceForge Logo

copyright 2003-2014