Zombie Infestation Simulator

For Project 2 you must build a simulator to explore the impact of the imminent zombie apocalypse. We will begin in Phase 1 with getting the basic pieces of the simulator together and then expand the functionality for the full project due the following week.

Phase 0: UML class diagram - Due Monday November 9 at 11:00 PM ET

Phase 1: Basic Human Movement - Due Monday November 16th at 11:00PM ET

Phase 2: Full Zombie Infestation - Due Monday November 23th at 11:00PM ET

UPDATE: you can submit Phase 2 until 11/30 at 11:00PM ET with no penalty (no late pass can be used on this project after this deadline) – please open an issue if you are done before 11/30 deadline

Important: Phase 0 and 1 are fairly simple, but Phase 2 will require a lot more work. Once you finish Phase 1 you should immediately continue to work on the requirements for the full project. DO NOT WAIT to start this project move through phases as soon as possible!

You can see an example of a finished zombie infestation simulator below. The white dots represent regular people, while the red dots show the ever growing zombie menace.

zombies

To get started:

  • Create your github repository using this link.
  • Look through the code and read the comments to learn what the different classes and functions do.
  • you can use any IDE you want, or solve your project in Repl.it
  • You are free to modify any code in the project (although there shouldn’t be any reason to modify DotPanel.java)

Phase 0: Planning stage (Due 11/9)

For this exercise you will do some planning for the full project

  • Your first task is to create a UML class diagram (no drawing pictures please use any UML software you want):

    • This should illustrate all the classes you expect to include in the FULL zombie infestation simulator project (Phase 2: described below).
    • List the most important functions and attributes for each class and use the different relationship arrows to illustrate which classes depend or inherit from others.
    • Use good objected oriented practices. Notably, you are strongly encouraged to avoid exposing data members from your classes. Instead, think about the functions that you should expose from a class so that it can help the other classes.

This portion of the project will be graded as an Exercise worth 10 points.

Phase 1: A Human World (Due 11/16)

For this exercise you will add functionality to create a random set of Humans that move about the city.

The starter code creates an empty city and draws it to the screen. You must add:

  • Humans that can be added to the city (by the City.populate() function). Humans should not be added inside of buildings (the gray areas)
  • Humans should move according to the following rules:
    • There is a ten percent chance each time step that it will turn to face a random direction
    • Move in the current facing direction by one square, unless there is a wall in the way (the Human always moves, even if it didn’t turn).
    • Note that humans are only drawn to the screen using a single dot—there is no visible way to see the direction a human is facing, but you should track it in your code.
    • This should give the impression of humans moving forward for several squares, then randomly turning and moving forward again.

Helper.java: The code includes a Helper class which you should use to generate any random numbers you need (this will allow us to easily set a single random seed used for all random number generation). The functions nextInt(max) and nextDouble() can be used to generate a random integer between [0…max) or a double between [0…1). Note how the Helper class uses static methods so you can access these functions without defining any object instances. You are free to add more useful functions to the Helper class.

Submission Phase 1

For this portion of the project you must include all of the following in your git repo:

  • Create a new branch called phase 1 and implement your phase 1 code in there
  • A screenshot of your program in action (gifs?)
  • Your code under phase1 branch

This portion of the project will be graded as an Exercise worth 10 points.

Keep in mind that the next portion of the assignment will require more complex coding and requires a written report… start as soon as possible!

Project 2: Zombies! Oh no! (Due 11/23)

For the full project you must:

  • Expand your world to include brain-eating zombies. Zombies will have a different set of rules than humans.
  • Redefine how Humans act so they will respond to zombies by attempting to run away. If a human is in an adjacent square to a zombie, the human’s brains are eaten and it becomes a new zombie.
  • Humans and zombies should not be allowed to pass through each other, or through buildings.
  • Improve the UI of the simulation to support keyboard short cuts to reset the simulation and mouse clicking to “drop” a new zombie at a particular location.

Zombie Rules:

  • When the simulation starts, a single zombie should be created in a random location.
  • If a zombie sees a Human within 10 squares of the direction it is facing (i.e., up, down, left, or right), then it moves towards that human
  • Otherwise, a Zombie has a 20% chance of turning in a random direction. The zombie moves forward whether it turns or not.
  • If a Zombie is adjacent to a human (not including diagonals), then it infects the human. The human then becomes a new zombie.

Updated Human Rules:

  • If a Human sees a Zombie within 10 squares of the direction it is facing, then the Human faces the opposite direction and attempts to run two squares away (subsequent moves will only be one square, unless the Human sees another zombie).
  • Otherwise the Human acts as before (10% random chance of turning, then move forward).
  • Humans that are adjacent to zombies get turned into new zombies as described above.

GUI Improvements:

  • Pressing the space bar should cause the zombie simulator to reset (regenerate buildings and humans, and add one zombie).
  • Clicking the mouse on the map should add a zombie at that location.

One more thing…

  • Finally, you must add one more feature of your choice to your simulator. Be creative: add a new rule for the humans or zombies, add extra functionality to the UI… anything you like as long as it is interesting. If you what you add is sufficiently awesome, you will get extra credit!

Project Submission

You will need to submit:

  • Your code
  • The UML Class diagram that represents your code (updated if you changed from your initial design)
  • A design document describing the components of your code and how they relate. This should make your code and the overall project understandable even to someone who has not read the assignment description. Also describe the “extra” feature you added and explain why it is cool. This must be created in the markdown file format. Word documents will make the grader VERY ANGRY (i.e., you will lose points).

Zombie Project 2 Rubric:

  • Phase 0 and 1 will be treated as an exercise each worth 10 points.
  • Phase 2 will count as a project graded as follows:
X / 15 pts Program compiles
X / 10 pts runs without errors
X / 10 pts Humans appear on screen and move randomly
X / 5 pts Humans avoid zombies within 10 spaces
X / 10 pts Zombies appear on screen and move randomly
X / 10 pts Zombies transform adjacent humans into zombies
X / 10 pts Clicking inside panel adds a zombie and pressing space resets program
X / 20 pts Good OOP design, comments, and style
X / 7 pts Writeup and UML diagram
X / 3 pts Includes extra feature
X / 5 pts Bonus for interesting extra feature
Total: X / 100 points