NAME
Game::Floppy::Bot - a bird flown once a tick, at one of three levels
VERSION
Version 0.10
SYNOPSIS
use Game::Floppy;
use Game::Floppy::Bot;
my $game = Game::Floppy->new(seed => $seed);
while ($game->status ne 'finished') {
$game->flap if Game::Floppy::Bot->choose($game, level => 3);
$game->tick;
}
DESCRIPTION
Asked once a tick, this says whether to flap: it flaps when the bird is below a target and not otherwise. The three levels differ in what the target is. Every target is at least 71 pixels down, a gap's centre at its highest, so no level can flap into the sky.
In a gap nothing dies: a flap band of 27 pixels fits a 140 pixel gap with room to spare. What kills is the drop between one gap and the next, 75 ticks and 225 pixels of fall against gaps whose centres lie anywhere in 300. A bird that starts down too late cannot get there.
- 1 short-sighted
-
A tube counts only once its left edge is within
near(120) pixels of the bird; until then the target is the middle of the field. - 2 far-sighted
-
The target is the next gap's centre from the moment the tube appears.
- 3 sits low
-
Far-sighted, but the target is the bottom of the gap, a radius and a flap's margin above the lower pipe: falling is slow and rising fast, so a bird waiting low loses nothing on a drop.
Nothing here calls rand and nothing is hashed: there are no ties to break. The bot is a set of class methods and keeps nothing between ticks.
METHODS
choose
my $flap = Game::Floppy::Bot->choose($game, level => 2);
1 to flap, 0 not to. The level is 1, 2 or 3 and defaults to 3. Undefined once the game has finished. A level off the ladder is a programmer error and dies.
target
my $y = Game::Floppy::Bot->target($game, 2);
The y the level is aiming the bird at this tick.
levels, describe, near
The ladder, (1, 2, 3); one line on what a level does; the distance at which level 1 starts to count a tube.
AUTHOR
LNATION, <email at lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2024 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)