Predation

By: Spatula Tzar

Spatula & Sickle

This is a little java project I made as a school assignment using Greenfoot. It served as a reminder of how much I hate java.

The sheep attempt to eat the grass, the alligator attempts to eat the sheep, and the sheep attempt to avoid being eaten.

There are three actors: Sheep, Alligators, and Grass. When the act command is used, the sheep go first. It selects which subroutine to do by priority (evade alligator, eat grass, seek grass, or wander around), then executes it. Once the action is complete, its turn is over and the next sheep moves.

After all sheep have moved, the alligators move. Once again it selects the subroutine based on priority (eat sheep, chase sheep, or do nothing), then executes it. Once the action is complete, its turn is over and the next alligator moves. After all alligators have moved, the round is over because the grass does not act.

A default subroutine is provided to populate the world with life.

Sheep

Wanders around until either grass or an alligator is spotted (within two squares). When grass is spotted, it moves towards it and attempts to eat it. When an alligator is spotted, it attempts to evade it. When both grass and alligator are spotted, the threat of predation takes priority.

Alligator

Conserves energy and does not move unless a sheep is spotted (within three squares), at which point it attempts to eat it.

Grass

Does not move or interact, but is secretly happy when a sheep is eaten.

~~Spatula Tzar
←Back

Bitcoin: 1KEWmWK3Sn9ToEHxhXmoXax6ycNGgLMfLv