In this document:
There are no attributes for this object type.
Every scan, a count is kept of how many amoeba have been found. For each amoeba found during the current scan, it does these things:
procedure ScanAmoeba(in positionType positionOfAmoeba;
in integer anAmoebaRandomFactor;
in Boolean amoebaSuffocatedLastFrame;
inout Boolean atLeastOneAmoebaFoundThisFrameWhichCanGrow;
in integer totalAmoebaFoundLastFrame;
inout integer numberOfAmoebaFoundThisFrame)
# Local variables
directionType direction;
positionType NewPosition;
ASSERT(anAmoebaRandomFactor > 0);
ASSERT(totalAmoebaFoundLastFrame > 0);
ASSERT(numberOfAmoebaFoundThisFrame > 0);
numberOfAmoebaFoundThisFrame++;
# If the amoeba grew too big last frame, morph into a boulder.
# kTooManyAmoeba = 200 for original Boulder Dash.
if (totalAmoebaFoundLastFrame >= kTooManyAmoeba) then
PlaceObject(objBoulder, attribStationary, positionOfAmoeba);
else
# If the amoeba suffocated last frame, morph into a diamond
if (amoebaSuffocatedLastFrame) then
PlaceObject(objDiamond, attribStationary, positionOfAmoeba);
else
# If we haven't yet found any amoeba this frame which can grow, we check to
# see whether this particular amoeba can grow.
if (not atLeastOneAmoebaFoundThisFrameWhichCanGrow) then
foreach direction in (up1, left1, right1, down1) do
if (GetObjectAtPosition(GetRelativePosition(positionOfAmoeba, direction)) in {objSpace, objDirt}) then
atLeastOneAmoebaFoundThisFrameWhichCanGrow := true;
endif
endforeach
endif
# If this amoeba decides to attempt to grow, it randomly chooses a direction,
# and if it can grow in that direction, does so.
if (AmoebaRandomlyDecidesToGrow(anAmoebaRandomFactor)) then
direction := GetRandomDirection();
NewPosition = GetRelativePosition(positionOfAmoeba, direction);
if (GetObjectAtPosition(NewPosition) in {objSpace, objDirt}) then
PlaceObject(objAmoeba, attribNone, NewPosition);
endif
endif
endif
endif
endprocedure
##
function AmoebaRandomlyDecidesToGrow(in integer anAmoebaRandomFactor):Boolean
# Randomly decide whether this amoeba is going to attempt to grow or not.
# anAmoebaRandomFactor should normally be 127 (slow growth) but sometimes is
# changed to 15 (fast growth) if the amoeba has been alive too long.
ASSERT(anAmoebaRandomFactor in {15, 127});
return (GetRandomNumber(0, anAmoebaRandomFactor) < 4);
endfunction