0% found this document useful (0 votes)
0 views7 pages

GridWordPart4_-_Challenge_Critters

Uploaded by

Varun Vijay Mani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

GridWordPart4_-_Challenge_Critters

Uploaded by

Varun Vijay Mani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Challenge Critters

• The following Critters are tougher. They all


follow the Critter template, but they are less
similar to the basic Critter.
• For each:
 Write a new class that extends Critter
 Do not override act, but do override other
methods as necessary.
 Create a Runner class that tests your new
type of Critter.
ChallengeCritter 1
A CaterpillarCritter is a Critter that only moves
forward. When it is unable to move forward
(because it is blocked by the edge of the Grid
or another Actor), it turns 90 degrees to the
right. CaterpillarCritter is a herbivore and eats
only Flowers.
ChallengeCritter 2
A CellCritter is one that replicates based on its
number of “cell neighbors” – neighbors of type
CellCritter. If the CellCritter has:
 No neighbors of type CellCritter - it dies (of
loneliness)
 5 or more CellCritter neighbors - it dies (of
overcrowding)
 1 - 3 CellCritter neighbors - it produces a new
CellCritter in a random neighboring empty cell (if
there is one available – if all are filled, it does
nothing).

CellCritters do not move.


(random)
ChallengeCritter 3
The HoarderCritter takes a Location into its constructor, which acts as its 'home'
location. HoarderCritter moves identically to a Critter, until it encounters another
Actor. When the HoarderCritter is adjacent to other Actors, it will choose 1
randomly and 'pick it up' by removing it from the Grid (but only 1 Actor at a time). If
the HoarderCritter is 'holding' another Actor, it will now move only towards its
'home' location, following these rules:
If it is in the same row or column as its home, it will move only along the axis in
the direction of its home. Otherwise, the HoarderCritter will check the locations
diagonally in the direction of home, along the x-axis only, and along the y-axis
only, and randomly choose between the options that are empty.
If the HoarderCritter is unable to move because it is blocked in all directions
described above or if it is on its home square, it will 'drop' the Actor it was holding
by putting it into the HoarderCritter's location, move away to a random empty
adjacent location, and revert to its previous behavior. If the Hoarder is unable to
drop its held Actor because it cannot move away (it is blocked on all sides), the
HoaderCritter removes itself from the grid and puts the held Actor in its old
location.
HoarderCritters will not pick up the same Actor twice.
(move random)

(holding Bug)

(home)
(home)

(holding Rock, (move random)


move semi-random)

You might also like