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:
classtypecommand
reserved for human players0
AISubmissive 3crap
AIEasy 1easy
AIAverage 4average
AIHard 2hard
AITest 5test
AIHardOld 6old
Framework scripted 9framework
Framework custom 7framework_custom
Framework best 8framework_best
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

     

News
Screen Shots
Change Log
FAQ
Chat/Discord

Support:

Become a Patron!

Play:

MacWindowsLinuxDownload

Download on the AppStore

Android App on Amazon AppStore

Android App on Huawei AppGallery

Android App on Google Play

Launches Flash GUI Domination

Share:

Develop:

Make Maps
Example Maps
Make Translation
Make AI

Bug Tracker (todo)
Discussion
Mailinglist (lobby)

Links:

Domination Project Page on SourceForge

Lobby Web Site on SourceForge

Lobby Project Page on SourceForge

SourceForge.net Logo

copyright 2003-2024 yura.net