next up previous
Next: Project 3: Efficient Golf Up: W4444 Programming and Problem Previous: Project 1: Olympic Road

Project 2: Predators and Prey

In this project, we'll simulate the hunting of a single fast animal (say a rabbit) by a team of slower predators (say hungry cave-men). The action takes place on the computational savannah that, as everybody knows, is a 100x100 grid. Let $m$ be the number of cave-men on the savannah; we'll vary $m$ to see how effective hunting can be in different-sized teams.

The rabbit always starts out at the center of the grid at (50,50). The cave-men start at random cells, but will always start outside of the square bounded by (40,40) and (60,60). For every move that the cave-men make, the rabbit gets to make $r$ moves, where $r$ is a positive integer. (We'll also vary $r$ to see how fast a rabbit has to be to escape predation.) A move can be to any adjacent square, orthogogonally or diagonally, like a king in chess. A rabbit or a cave-man can also choose to stay put on their turn to move. One cannot move off the edge of the board. The rabbit starts out by making $r$ moves, at which time the cave-men each get to make one simultaneous move. Then the rabbit makes $r$ more moves, and so on. Two cave-men can occupy a single cell if they wish, but it is likely to be more effective for the cave-men to spread themselves out.

The cave-men win if, at any point during the game, the rabbit is one square away from a cave-man. (The cave-man reaches out and grabs the rabbit.) The rabbit wins if it can indefinitely hold off the cave-men. In practice, we'll run the simulation for some large number of moves, and if the rabbit hasn't been eaten it will be declared the winner.

Your job is to write two programs, one to guide the rabbit, and one to guide the cave-men. Complete information about the state of the simulation (i.e., where all of the participants are and the current move number) is available to both programs. Since the cave-men act in a cooperative fashion, they follow a single set of coordinated instructions, rather than each acting individually.

At the end of the project, we'll run a bunch of competitions between the various rabbit and cave-man programs. We'll run a variety of configurations. Cave-men should usually win when $m$ is large and $r$ is small. (How large/small?) Rabbits should usually win when $m$ is small and $r$ is large. There will be an interesting middle ground where the outcome is variable -- this middle ground will separate the cave-men from the cave-boys!

As always, the competitions are for fun and pride, and are there to stimulate the development of ideas. It is the ideas themselves that will be assessed. A loosely-related problem called Angels and Devils was proposed by John Conway.


next up previous
Next: Project 3: Efficient Golf Up: W4444 Programming and Problem Previous: Project 1: Olympic Road
Ken Ross 2006-10-18