GridWorld

GridWorld is a computer program case study written in Java that was used with the AP Computer Science program from 2008 to 2014.[1] It serves as an example of object-oriented programming (OOP). GridWorld succeeded the Marine Biology Simulation Case Study, which was used from 2000–2007. However, GridWorld has now been discontinued as of the 2014–2015 school year, in favor of three optional labs.

The GridWorld framework was designed and implemented by Cay Horstmann, based on the Marine Biology Simulation Case Study. The narrative was produced by Chris Nevison and Barbara Cloud Wells, Colgate University.

Actors

The GridWorld Case Study employs an Actor class to construct objects in the grid. The Actor class manages the object's color, direction, location, what the object does in the simulation, and how the object interacts with other objects.

Actors are broken down into the classes "Flower", "Rock", "Bug", and "Critter", which inherit the Actor class and often override certain methods (most notably the Act method). Flowers can't move, and when forced to Act, they become darker. Flowers are dropped by Bugs and eaten by Critters. Rocks are also immobile and aren't dropped or eaten. Bugs move directly ahead of themselves, unless blocked by a rock or another bug, in which case the Bug will make a 45 degree turn and try again. They drop flowers in every space they occupy, eat flowers that are directly on their space of grid, and are consumed by Critters. Critters move in a random direction to a space that isn't occupied by a Rock or other Critter and consume Flowers and Bugs.

Extensions

The Case Study also includes several extensions of the above classes. "BoxBug" extends "Bug" and moves in a box shape if its route is not blocked. "ChameleonCritter" extends "Critter" and does not eat other Actors, instead changing its color to match the color one of its neighbors. "Crab Critter" moves left or right and only eats Actors in front of it, but otherwise extends the "Critter" class.

Students often create their own extensions of the Actor class. Some common examples of student created extensions are Warden organisms and SimCity-like structures, in which objects of certain types create objects of other types based on their neighbors (much like Conway's Game of Life). Students have even created versions of the games Pac-Man, Fire Emblem, and Tetris.

Known issues

The version that is available at the College Board website, GridWorld 1.00, contains a bug (not to be confused with the Actor subclass Bug) that causes a SecurityException to be thrown when it is deployed as an applet. This was fixed in the "unofficial code" release on the GridWorld website. Also, after setting the environment to an invalid BoundedGrid, it will cause a NullPointerException.

References

  1. Horstmann, Cay. "GridWorld". horstmann.com. Accessed September 15, 2008.

External links

This article is issued from Wikipedia - version of the Friday, May 08, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.