Carnegie Mellon University

ActiveTutors Project

GridCity Overview


Introduction

A gradual introduction to programming while exposing the user to real Java language and environment. The users/students write programs in Java to control agents in an environment.

Background

It is closely related to Karel the Robot. Karel provided a robot in a world. The robot could move forward and turn left. Karel was also capable of picking up or putting down "beepers" and detecting walls. The purpose of Karel was to introduce the student to programming while removing the overhead required to use a real computer language or programming environment.

Also related to Logo. Logo was not grid based (it used real valued coordinates), but it did make the effects of the program visible. Logo used a pen to draw. It provided a cross between geometry and programming.

Methods

The simulator provides a stimulating environment for the students to experiment with with programs and to watch the progress of their program.

Vehicles (agents) in a World (environment). Vehicles, Walls, and Parcels are located on the corner or intersections where Avenues and Streets meet. The students write actual Java code to control the vehicles.

Vehicles have purposefully limited capabilities : turn left, move forward, pickup or deliver parcels. They can also check for walls immediately in front of or to the sides and can check for parcels in the vehicle or on the corner with the vehicle.

The main feature is the Grid itself. The grid represents the avenues (which run north-south) and streets (which run east-west) in the city. This displays the current state of the city -- the walls, the parcels, and the vehicles. Walls are represented by grey squares. Parcels appear as small icons in the lower right corner of an intersection. The parcel icon will appear whenever the is one or more parcels on that corner.

Below the grid is a status line for each vehicle. This line reports on the location of the vehicle, the number of parcels that the vehicle is carrying, and the number of parcels on the corner with the vehicle.

Above the grid are buttons that allow a student to start a program running and to halt its execution. The step button allows the student to step through the visible actions (turning, moving, pickup and delivery).

Example

The explicit goals of programs written in GridCity are usually to harvest fields of parcels, sorting columns of parcels, or navigating a maze of walls.

Such programs can be very simple such as turning to face East, drive up to a wall then search for an opening and drives through that. More complex programs are certainly possible. It is also possible to sub-class the Vehicle objects to extend their behaviors. This would give the Vehicle the ability to turn right, for instance.

Since the entire system is written in Java, students can expand on this base and develop more complex programs which make use of Java control structures, features, and other classes.

The simulator includes a world editor to allow users to create custom city maps. The editor uses the standard display and adds a separate control panel to control the placement of walls, vehicles, and parcels.

By simply clicking on the display and then adding or removing walls, vehicles and parcels, a new city can be created.

The configuration of a city is stored in a world file (.gcw). The size of the city, the location of walls, the locations of parcels, and the location of vehicles with the number of parcels they contain may be specified. The format is very simple. Each line maybe one of the following:

      <number of avenues>,<number of streets> world
      <avenue>,<street> wall
      <avenue>,<street> parcel <number of parcels>
      <avenue>,<street> vehicle <number of parcels> <initial direction>

Discussion

Design decisions were made to simplify the use of the simulator for students.

Within GridCity we can teach the students how to decompose problems and how to engage in step-wise refinement. Because it is implemented in Java we can also use it to teach object oriented programming. Further is will allow us to explore a new paradigm that we call multi-agent programming (also known as or related to autonomous agent or event driven programming).

there are two goals for grid city:

This specific piece is really just a simplified environment for the students to work with. It insulates them from many of the particular details of Java (events, threads, images) while providing the students with an environment which they can see what their programs are doing and they can use it to explore how to program in Java. This allows the students to focus on _how_ their programs work

Related links at this site


Summer 1999 ActiveTutors Project [tutors@cs.heinz.cmu.edu]