CS 231: Assignment #6

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

Problem Description

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.

Tasks

  1. Grab the revised files below (only Agent has actually changed). The changes to Agent are:
    1. that it must be able to recall the last position of the Agent (lastx and lasty),
    2. that the postUpdateRule returns a boolean which, if true, causes the Agent to be deleted from the Landscape, and
    3. an undraw function that removes the icon of the entity from the landscape.
    The updated files are here.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Once you have a working simulation, go back and revise your design document to take into account any changes.

Extensions

  1. 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.
  2. 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.
  3. Make other modifications.
  4. Build one of the other simulations.
  5. Designs that are exceptionally well presented will receive extension credit.

Handin

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.

Once you have written up your assignment, give the page the label:

cs231f09project6

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.