Assignment 1


This programming assignment is the first of a series of assignments centered around a common theme. The idea is to get some programming practice in Java, while also improving programming skills (for example: critical thinking, problem solving, software engineering).

In this assignment, you will simulate a stock-car race featuring several vehicles on a 2-dimensional grid of cells. Essentially, think of the grid as a 2-dimensional array and the vehicles as integers. Then, each vehicle will start at some location (a particular cell, such as (2,3)) and be assigned a destination location (such as (9,6)). At every time step, each vehicle gets its chance to move towards its assigned destination by a distance of one cell (horizontal or vertical, but not diagonal). A vehicle cannot move into an occupied cell, allowing for the possibility of a "standoff". In this case, both vehicles stay in the "standoff" until one of them can move or the simulation ends. The overall goal is to estimate the fraction of vehicles that make it to their destination, and to do this for various parameters.

This vehicle simulation that you will write is part of a long tradition of simulating "macro" behaviors (for example: traffic congestion) that arise from groups of independent small units (vehicles). This type of simulation is often called an agent or artificial society simulation. Indeed, there is a whole institute, the Santa Fe Institute, devoted to such studies. In keeping with tradition, we will sometimes refer to the vehicles as agents. (Think "agents driving vehicles").

Start by downloading this JAR file. (Note: we had some problems downloading this file with Netscape on Win98/NT - you might try Internet Explorer instead. Also, save it as a file - it's not viewable). A JAR file is really a ZIP file containing other files. Use the Java command-line tool jar to "unpack" the JAR file. For example, on Unix, you would type:

% jar xvf assign1.jar
  
Here, the xvf string is a list of options. After unpacking, you should see several .class files and one Java source file, Assign1.java, your starting template. For more help with the jar tool, simply type jar at the command line.

Examine the file Assign1.java and observe the following:

You are to write your code in the main() method as well as methods you create. Note the following:

Deliverables:

Submission: