Project 2: Braiiiiinnnnsssss
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 1: Basic Human Movement - Due Thursday November 8th at 11:59PM
Phase 2: Full Zombie Infestation - Due Sunday November 18th at 11:59PM
Important: Phase 1 is 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.
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.
Phase 1: A Human World (Due 11/8)
For this exercise you will do some planning for the full project and then take the provided project skeleton and add functionality to create a random set of Humans that move about the city.
To get started:
- Create your github repository using this link.
- Import the git repo into a new IntelliJ project:
- Choose
Check out from Version Control -> git
in the welcome window, or chooseVCS -> Check out from Version Control -> git
- Enter your git URL generated by the GitHub Classrooms tool
- Keep hitting “Next” or “Yes” until it opens a new window with the project you cloned.
- Note: Always use one of the two options listed above. Do NOT try to do File->New… It won’t work correctly!
- For instructions on installing IntelliJ - see the Collections Lab.
- Choose
- Look through the code and read the comments to learn what the different classes and functions do.
- You are free to modify any code in the project (although there shouldn’t be any reason to modify
DotPanel.java
)
Planning stage:
- Your first task is to create a UML class diagram either on paper or with a tool such as Violet UML editor. This should illustrate all the classes you expect to include in the FULL zombie infestation simulator project (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.
Implementation: 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:
- Your UML class diagram
- A screenshot of your program in action. If you don’t know how to take a screenshot try this
- Your code
- Check the IntelliJ Tips for instructions on how to commit and push your code, plus other common errors.
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 soon!
Project 2: Zombies! Oh no! (Due 11/18)
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.
- 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).
- Check the IntelliJ Tips for instructions on how to commit and push your code, plus other common errors.
Zombie Project 2 Rubric:
- Phase 1 will be treated as an exercise 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