| Games-Risk documentation | view source | Contained in the Games-Risk distribution. |
Games::Risk::AI - base class for all ais
version 3.103040
[don't use this class directly]
This module is the base class for all artificial intelligence. It implements
also a POE session representing an AI player. This POE session will retain the
Games::Risk::AI::* object as heap.
Create a new AI of type $AItype. Note that you should not instantiate a
Games::Risk::AI object directly: instantiate an AI subclass instead. All
subclasses accept the following parameters:
Game::Risk::Player associated to the AI. (mandatory)Note that the AI will automatically get a name, and update the player object.
This method will create a POE session responsible for the artificial
intelligence $ai. It will return the poe id of the session newly created.
The session will also react to the ai's player name (poe alias).
An AI object will typically implements the following methods:
Return the attack plan, which can be either attack or attack_end to stop
this step of the ai's turn. If attack is returned, then it should also
supply $from and $country parameters to know the attack parameters.
Return the number of armies to move from $src to $dst after a
successful attack (minimum $nb to match the number of attack dices).
Return a short description of the ai and how it works.
Return a difficulty level for the ai.
Check if ai can trade some @cards for armies.
Return a list of [ $src, $dst, $nb ] tuples (two
Games::Risk::Country and an integer), each defining a move of
$nb armies from $dst to $src.
Return a list of [ $country, $nb ] tuples (a Games::Risk::Country
and an integer) defining where to place $nb armies. If $continent (a
Games::Risk::Continent) is defined, all the returned $countries
should be within this continent.
Note that some of those methods may be inherited from the base class, when it provide sane defaults.
Jerome Quelin
This software is Copyright (c) 2008 by Jerome Quelin.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
| Games-Risk documentation | view source | Contained in the Games-Risk distribution. |