Acme-RTB

 view release on metacpan or  search on metacpan

RTB/RTB.pm  view on Meta::CPAN

package Acme::RTB;

use 5.008;
use strict;
use warnings;
use IO::Select;
use IO::Handle;

our $VERSION = '0.01';


=head1 NAME

Acme::RTB - Perl extension for building realtimebattle bots

=head1 SYNOPSIS

  use Acme::RTB;
  my $robot = Acme::RTB->new({  Name    => 'Anarion PerlBot 1.0',
                                Colour  => 'ff0000 ff0000',
                                Log     => '/home/anarion/perl/rtb/robot.log'} );

  $robot->Start;

=head1 DESCRIPTION

This module will allow you to create bots for battling with realtimebattle.
L<http://realtimebattle.sourceforge.net/>

=head1 METHODS

=over 4

=head2 new

=back

First create an object, you should pass a hashref with the Name, Colour and if you
will the logfile.

  my $robot = Acme::RTB->new({  Name    => 'Anarion PerlBot 1.0',
                                Colour  => 'ff0000 ff0000',
                                Log     => '/home/anarion/perl/rtb/robot.log'} );


=over 4

=head2 modify_action

=back

With this method you can change all the actions that your bot do when it recieves
a msg from the server, the possible actions are:

                Initialize
                YourName
                YourColour
                GameOption
                GameStarts
                Radar
                Info
                RobotInfo
                RotationReached
                Energy
                RobotsLeft
                Collision
                Warning
                Dead
                GameFinishes
                Unknown


$robot->modify_action(  Radar           => \&my_radar    );

$robot->modify_action(  GameStarts      => \&my_gamestart);

$robot->modify_action(  Collision       => \&my_collision);

Here are the parameters that you recieve from the server:


=head3 Initialize [first? (int)]


This is the very first message the robot will get. If the argument is one, it is the first sequence in the tournament and it should send Name and Colour to the server, otherwise it should wait for YourName and YourColour messages (see below).

=head3 YourName [name (string)]



( run in 0.617 second using v1.01-cache-2.11-cpan-df04353d9ac )