- GridWorld
GridWorld is a computer program case study written in Java for use with the AP
Computer Science program. [Horstmann, Cay. [http://www.horstmann.com/gridworld/ "GridWorld".] "horstmann.com". Accessed September 15, 2008.] It serves as an example ofobject-oriented programming (OOP) embedded in a more complicated design project than most students have worked with before. GridWorld is the successor to theMarine Biology Simulation Case Study , which was used from 2000-2007.The GridWorld framework was designed and implemented by [http://horstmann.com 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
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 the game of Life).
References
External links
* [http://gridworld.info/ GridWorld.info] Unofficial GridWorld Site
* [http://apcentral.collegeboard.com/apc/public/courses/teachers_corner/4483.html College Board AP Computer Science Page]
Wikimedia Foundation. 2010.