CSC204 - Project 2
Swarming with Objects

Assigned April 8th
Due April 15th 4:45pm


Overview

In this project, you will implement a Java program to display swarming patterns and properties of social networks.

Swarms

Some of the simplest objects we can explore involve simulating the behavior of animals. Our choice for this project will be Ants. Scientists study the simple behavior of ants, termites, fish, and other animals to try and learn rules for crowds and social interaction.

Two swarms of ants following the leader

An ant is defined to be at a particular point in space, specified by x and y coordinates. Each ant is also given one friend, someone else (not themselves) to follow around. Every second, an ant will perform three behaviors

  1. Move 1/2 the distance between itself and its friend.
  2. Wiggle and move randomly.
  3. Move away from the closest Ant if that Ant is too close.
Your task is to create two instantiable classes which capture an x,y Point, and an Ant which will swarm. Through these objects, you will be able to explore the grouping effects of social networks. In particular, you can study how many groups are formed through these simple rules of follow the leader.

What to do

You have been given the main method of Swarm.java. The comments in this class explain the steps of reading data from the user, initializing all of the Ants, and running the simulation as described above.

Point Class

The first class you will implement is Point.java

Data Members

Methods

You can add a main method to this class for unit testing, and should, but it is not necessary.

Ant Class

The second class you will implement is Ant.java

Data Members

Methods

You can add a main method to this class for unit testing, and should, but it is not necessary.

How to approach this project

I recommend working from the bottom up. First, create the Point class and test all of its methods. Then create an Ant class, which uses Points, and test all of its methods. Use stubs to make code that will compile but have limited functionality. This will let you work on the move method separate from the wiggle or repel methods.

What to turn in

You should hand in three files to your file space on the cs.centenary.edu server, following the instructions of Lab 1. The files are

Place these files in a directory called project2.