Games::Risk::AI - base class for all ais
[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.
Games::Risk::AI::*
my $ai = Games::Risk::AI::$AItype->new( \%params )
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:
$AItype
Games::Risk::AI
player: the Game::Risk::Player associated to the AI. (mandatory)
Game::Risk::Player
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).
$ai
An AI object will typically implements the following methods:
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 @where = place_armies($nb, [$continent])
Return a list of [ $country, $nb ] tuples (a Games::Risk::Map::Country and an integer) defining where to place $nb armies. If $continent (a Games::Risk::Map::Continent) is defined, all the returned $countries should be within this continent.
[ $country, $nb ]
Games::Risk::Map::Country
$nb
$continent
Games::Risk::Map::Continent
$countries
Note that some of those methods may be inherited from the base class, when it provide sane defaults.
Games::Risk.
Jerome Quelin, <jquelin at cpan.org>
<jquelin at cpan.org>
Copyright (c) 2008 Jerome Quelin, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Games::Risk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Risk
CPAN shell
perl -MCPAN -e shell install Games::Risk
For more information on module installation, please visit the detailed CPAN module installation guide.