NAME
Games::Risk::AI - base class for all ais
VERSION
version 4.000
SYNOPSIS
[don't use this class directly]
DESCRIPTION
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.
METHODS
Constructor
my $ai = Games::Risk::AI::$AItype->new( \%params )
Create a new AI of type
$AItype. Note that you should not instantiate aGames::Risk::AIobject directly: instantiate an AI subclass instead. All subclasses accept the following parameters:player: the
Game::Risk::Playerassociated to the AI. (mandatory)
Note that the AI will automatically get a name, and update the player object.
my $id = Games::Risk::AI->spawn( $ai )
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).
Object methods
An AI object will typically implements the following methods:
my ($action, [$from, $country]) = $ai->attack()
Return the attack plan, which can be either
attackorattack_endto stop this step of the ai's turn. Ifattackis returned, then it should also supply$fromand$countryparameters to know the attack parameters.my $nb = $ai->attack_move($src, $dst, $min)
Return the number of armies to move from
$srcto$dstafter a successful attack (minimum$nbto match the number of attack dices).my $str = $ai->description()
Return a short description of the ai and how it works.
my $str = $ai->difficulty()
Return a difficulty level for the ai.
my @cards = $ai->exchange_cards()
Check if ai can trade some
@cardsfor armies.my @moves = $ai->move_armies()
Return a list of
[ $src, $dst, $nb ]tuples (twoGames::Risk::Countryand an integer), each defining a move of$nbarmies from $dst to$src.my @where = $ai->place_armies($nb, [$continent])
Return a list of
[ $country, $nb ]tuples (aGames::Risk::Countryand an integer) defining where to place$nbarmies. If$continent(aGames::Risk::Continent) is defined, all the returned$countriesshould be within this continent.
Note that some of those methods may be inherited from the base class, when it provide sane defaults.
SEE ALSO
AUTHOR
Jerome Quelin
COPYRIGHT AND LICENSE
This software is Copyright (c) 2008 by Jerome Quelin.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007