Question: simulation of a zombie apocalypse using Python Specifications We will be simulating the infection of humans by zombies on a 2D map of a size
simulation of a zombie apocalypse using Python



Specifications We will be simulating the infection of humans by zombies on a 2D map of a size of your choosing. The simulation will show a scatter plot containing humans, zombies, food, water and medic kits. On each timestep the zombies and humans will move and interact with each other as well as with the food, water and medic kits. Timesteps The heart of your program will be a loop that controls how many timesteps the program runs for. This loop will control all the other functionality, movement etc. Your program should accept 3 command line parameters but default to reasonable options in the case of their absence. The command line parameters are as follows: Initial number of humans Initial number of zombies Number of timesteps in the simulation Objects Both humans and zombies should be represented in the code as objects. Humans should have health and age variables and zombies only a health variable. They should also have methods for their various actions, such as moving, attacking, biting etc. The methods you have are up to you. Humans start with a health of 100 at the beginning of the similation and loose 1 health point for every step they move (see the movement section). Humans also start with a random age between 20 and 60 and at every timestep they age by 1. Humans don't live past 80 timesteps. Zombies start with the health that they had as a human before becoming infected. They don't have an age and only lose health by being bitten by other zombies (see the interaction section). Food, water and medic kits could also be represented using objects but don't have to be. The initial locations of food, water and medic kits are up to you. Movement Humans and zombies both move randomly. Humans can move up to 6 spaces (steps) in any direction. Zombies can move up to 3 spaces (steps) in any direction. Neither humans or zombies should be able to go off the map. Food, water and medic kits don't move. Interactions Humans and zombies should interact with each other as well as items on the map (food, water and medic kits). An interaction occurs when a human or zombie is on any of the 8 positions surrounding something else (e.g. a human, a zombie, food, water, a medic kit). When an interaction occurs you should print the interaction and the result to the terminal (i.e. a zombie was killed by a human, a human just drank water etc). The human and zombie interactions types are as follows: Human and human interaction: some people are selfish and others are helpful. When two humans interact there is a 50% chance that one human uses the other to gain 20 health, which means the other loses 20 health. There is also a 50% that the humans help each other and both gain 10 health. Human and zombie interaction: zombies like biting. When a human and zombie meet the human has a 80% chance of being bitten by a zombie and becoming a zombie. The zombie has a 20% chance of being killed by the human. Zombie and zombie interaction: zombies like biting, so much they can't help but sneak in a cheeky bite at any opportunity they get. As a result, when zombies come into contact they bite each other, with the result being that both zombies lose 10 health. The water, food and medic kit interactions types are as follows: Human water interaction: gains 50 health, food (no effect on zombies) Human food interaction: gains 30 health (no effect on zombies) Human medic kit interaction: gains 100 health (no effect on zombies) Visualisation of results Your program should display a scatter plot for each timestep with the current positions of all the humans and zombies. The items on the map should vary in colour, shape and size. For example, humans could be green circles, zombies red circles, food brown squares, water large blue squares and medic kits red crosses. It is up to you what colours, shapes and sizes you use. Parameter sweeps Create a parameter sweep to run the program with an initial human population of 10 to 50 with an initial zombie population of 1 to 10. Save the final plot of each simulation run by the parameter sweep. Also save the initial and final human and zombie populations (4 values) of each simulation as one row in a CSV file (each running of the parameter sweep bash file will just produce one CSV file). You can use this data in your report. Coding Standard Your code submission must conform to coding standards emphasised in the lecture and practicals. Your code should also make use of multiple functions to reduce code duplication. Your code should also follow the program layout structure on slide 52 of lecture 4. Note, your code won't look the same as the code on that slide but the order of the sections should be the same. Remember, consistency is key
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
