AI

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

     

Change Log svn

VOTE/DONATE FOR NEXT FEATURE

News
Screen Shots
Download

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

FAQ
Make Maps
Extra Maps
Make Translation
Make AI

Bug Tracker todo
Mailinglist
Discussion Comments

Domination Project Page on SourceForge

Domination Project Page on Freshmeat R

Lobby Web Site on SourceForge

Lobby Project Page on SourceForge

SourceForge.net Logo

copyright 2003-2014 yura.net