Acme-RTB
view release on metacpan or search on metacpan
=head2 Shoot [shot energy (double)]
=back
Shoot with the given energy. The shot options give more information.
=over 4
=head2 Print [message (string)]
=back
Print message on the message window.
=over 4
=head2 Debug [message (string)]
=back
Print message on the message window if in debug-mode.
=over 4
=head2 DebugLine [angle1 (double)] [radius1 (double)] [angle2 (double)] [radius2 (double)]
=back
Draw a line direct to the arena. This is only allowed in the highest debug level(5), otherwise a warning message is sent. The arguments are the start and end point of the line given in polar coordinates relative to the robot.
=over 4
=head2 DebugCircle [center angle (double)] [center radius (double)] [circle radius (double)]
=back
Similar to DebugLine above, but draws a circle. The first two arguments are the angle and radius of the central point of the circle relative to the robot. The third argument gives the radius of the circle.
=head1 EXAMPLES
My hello botworld:
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;
Example two:
#!/usr/bin/perl
use strict;
use warnings;
use lib "/home/anarion/perl/rtb";
use Acme::RTB;
my $robot = Acme::RTB->new({ Name => 'Killer Montses',
Colour => 'ff0000 ff0000',
Log => '/home/anarion/perl/rtb/anarion.log'} );
$robot->modify_action( Radar => \&my_radar );
$robot->modify_action( GameStarts => \&my_gamestart);
$robot->modify_action( Collision => \&my_collision);
$robot->Start;
sub my_radar
{
my ($self, $dist, $obj, $angle) = @_;
for($obj)
{
/0/ && do { robot($dist,$angle) };
/1/ && do { dodge($dist,$angle) };
/2/ && do { turn($dist,$angle) };
/3/ && do { cookie($dist,$angle) };
/4/ && do { mine($dist,$angle) };
}
}
sub my_gamestart
{
my $self = shift;
my $speed = rand(1)+1;
my $angle = rand(0.4)-0.8;
$self->Accelerate($speed);
$self->RotateAmount(7,rand(2),rand(5));
}
sub my_collision
{
my ($self, $object_type, $angle) = @_;
$robot->RotateAmount(7,rand(2),rand(5)-2.5);
}
sub robot
{
my ($dist, $angle) = @_;
$robot->RotateTo(7,2,$angle-0.2);
$robot->Shoot(10);
}
sub dodge
{
$robot->RotateAmount(7,2,1);
}
( run in 1.831 second using v1.01-cache-2.11-cpan-99c4e6809bf )