Zombies v. Dragons
The idea this week is to re-implement one of the prior simulations--the social simulation--to see how well our design works. The result of this effort may encourage us to refine our design.
Documentation for Java 1.5 is located at: Java 1.5 SE API.
Documentation for Java 1.6 is located at: Java 1.6 SE API
The design for the system will build off our main concept of a continuous landscape with Agents making decisions about their movement.
You'll complete your first simulation with the new system by rebuilding the social agent system from lab 2.
Grab the revised files below (only Agent has actually changed). The
changes to Agent are:
- that it must be able to recall the last position of the Agent (lastx and lasty),
- that the postUpdateRule returns a boolean which, if true, causes the Agent to be deleted from the Landscape, and
- an undraw function that removes the icon of the entity from the landscape.
- Landscape - the Landscape class is the most challenging piece. Once it is finished, however, we can build many different systems fairly easily. Use the Landscape skeleton file as the basis for building it.
- As many of the Agent functions in the interface are common across agents, you probably want to make an AgentParent class that handles things like x, y, setPosition, and lastx, lasty. It can also have default draw methods and a default postUpdateRule method that just returns false.
- Once you have an AgentParent class, you can create a SocialAgent class that implements the social simulation from lab 2. Keep it simple with just two types. The update rule should get the list of neighbors, search it for like/unlike, and then move randomly (use the nextGaussian function) if it's unhappy. It also helps if the SocialAgent moves with a small random probability no matter what.
- Create a SimulationSocial class that overrides the Initialize method of Simulation. It should put the specified number of SocialAgents in random locations on the Landscape. Otherwise, all you need is a constructor. I'd suggest enabling it to adapt to any number of types.
- Run your simulation. On a landscape with a 40x40 extent, give each SocialAgent a vision of not more than 3 or 4. If their vision is too large, the result is unstable. Test this hypothesis yourself with several different runs with the entities with different vision distances.
- Once you have a working simulation, go back and revise your design document to take into account any changes.
- Add a Zombies extension to the social simulation. Each turn, a zombie has a 25% chance of turning one randomly selected agent within its field of vision into a zombie. You can do this by modifying the SocialAgent update rule.
- Add a Dragon extension to the social simulation. Each turn, a dragon has a 50% chance of catching each zombie within its field of vision. Try putting just a few Dragons into the system. Since this involves removing agents, you have to be a little more careful.
- Make other modifications.
- Build one of the other simulations.
- Designs that are exceptionally well presented will receive extension credit.
Make your writeup for the project a wiki page in your personal space. If you have questions about making a wiki page, stop by my office or ask in lab.
Your writeup should have a simple format.
- A brief description of the overall task, in your own words.
- As explanation of your solution, focusing on the interesting bits. The most interesting Make sure it has enough detail so that when you sit down to write the code it is clear what you want to do. Any extensions you did are interesting.
- Printouts, pictures, or results to show what you did. You can do screen captures of your terminal to show the initial and final landscapes.
- Other results to demonstrate extensions you undertook. If you tried different update rules, for example, show how those affected the overall simulation results. A graph of the number of Entities over time would also be helpful.
- A brief conclusion and description of what you learned.
Once you have written up your assignment, give the page the label:
You can give any page a label when you're editing it using the label field at the bottom of the page.
Do not put code on your writeup page or anywhere it can be publicly accessed. To hand in code, put it on the Academics server in your folder within the COMP/CS231 directory.