Predators and Preys
Link: sketch, fullscreen
Date: 04/23/2019
For this week’s assignment, I explored predator-prey interactions with autonomous agent. The predators detect preys and try to catch them, while the preys detect the predators and try to escape. The preys have three states – free, being eaten and dead. When the preys are dead, they will be removed. The predators also have three states. When the state is “full”, the predators don’t chase after the preys. When the state is “hungry”, the predators only go after the free preys. When the state is “so hungry”, the predators chase after the nearest prey regardless of the state of the prey.
A predator’s state is determined by a number which decreases continuously and increases when the predator eats a prey. The original size of the prey is added to the number once the size of the prey becomes zero. The problem is to update increase the number while the size of the prey is decreasing. When a predator is eating a prey, both the predator and the prey stop regardless of any interaction with other autonomous agents.
Users can press the mouse to set obstacles which only allow preys to go through. I have difficulty letting the predators check the boundaries of rectangular objects, so I only used circular boundary detection.