NAME

Game::Object::Worm::Bot - Worm

SYNOPSIS

Nah...

PROPERTIES

isRealPlayer

Whether this is a real life player or not.

Default: 0

probabilityTurnRandomly

The probability (0..1) that the Worm will turn randomly for every move forward.

Default: 0 (no turning)

probabilityTurnTowardsPrize

The probability (0..1) that the Worm will turn towards a prize when it's on the same line.

Default: 0 (no turning)

METHODS

new([$left = 11], [$top = 12], [$direction = "left"], [$length = 3)

Create new Bot Worm, facing in $direction ("left", "right", "up", "down" (only left supported right now)), with a body a total size of $length.

cloneValuesFrom($oObject)

Clone important values (like probabilities etc, not location and direction etc.) from $oObject into $self.

Return 1.

moveForward()

#Possibly turn left/right (percentChanceTurn() chance that #will happen).

Move forward one step in the oDirection. If that's not possible, try to turn left or right. If that's not possible, fail.

Return 1 on success, else 0.

randomDirection()

Return "left" or "right", randomly.

oppositeDirection($direction)

Return the opposite of $direction ("left" or "right").

possiblyTurnRandomly()

If probabilityTurnRandomly(), turn left/right

Return the turned direction ("left"/"right") or "" if no turn was made.

possiblyTurnTowardsPrize()

If probabilityTurnTowardsPrize(), turn left/right

Return the turned direction ("left"/"right") or "" if no turn was made.