Description
Objective
This program provides an opportunity to practice use of two-dimensional arrays.
Overview & Instructions
Anticipating the inevitable zombie apocalypse, the government has challenged you with the task of creating a model
that will describe how quick a group of zombies move from a starting point to cover a given area.
The walking area can be seen as an n-by-n two-dimensional array. A number of zombies will start at the center. Each
zombie individually can only make one step at a time to the left, right, up, or down (with an equal chance for any
direction). Be sure to take into account the boundary cells to disallow zombines from leaving the area. You will need
to “mark” the array cells visited by the zombies. Once marked, these stay marked even considering a zombie may
return to the zone.
An example scenario could be what you see below. Four zombies start in the middle. Each one can move in any
direction. Note the locations of the zombies after 1 step and further with two steps. The gray cells are marked as
visited. Since the movement of the zombies is random and there is an equal chance they could move in any direction
(excluding out-of-bounds moves), this is only one of many scenarios.
4
1 1 1
2 1
Start After 1 Step After 2 Steps
Your simulation input should include two variables: the number of zombies and the dimensions of the grid. These
could be via program constants or as user input. The simple output of the simulation is to be the number of steps
required to mark the entire grid area.
Your program should help to formulate and test a hypothesis about the number of steps taken before all cells are
touched. Run the program several times in order to report back to the government bosses with a summary of steps as
a function of grid size and zombie count.
Finally, include a feature that would allow someone (i.e. your instructor) to see your simulation to validate correctness.
This does not imply the use of a graphical user interface, but instead could be a feature that could be enabled to send
text messages to the console to show the step-by-step behavior of your zombies in motion.