A pandemic simulator, made as a mock technical interview assignment from aNewSpring.
A Java simulator modelling the spread of a virus on a grid of n*n
persons over the course of r
rounds.
Rules of the simulator:
- The virus spreads through contact with adjacent (including diagonals) people.
- A person with more than
i
infected adjacent contacts will become infected. - An infected person with more than
rc
infected adjacent contacts will recover and become uninfected.
Program arguments expected (in order):
java pandemic n r i rc [<x,y>,<x,y>...]
n
: grid sizer
: rounds of simulationi
: infection thresholdrc
: recovery threshold- coordinates of infected persons at start (upper left corner coordinates being 1,1)
Example:
java pandemic 8 7 2 6 [<4,7>,<4,8>,<5,8>,<6,8>]
launches a simulation with: a grid size of 8, 7 rounds, with an infection threshold of 2 and a recovery threshold of 6, and 4 infected persons at the listed coordinates.
run with above example parameters
Algorithms for solving Conway's Game of Life, on which this exercise is based