As mentioned previously, we recreated a classic arcade game in the Advanced Placement Computer Science case study GridWorld.
GridWorld involves programming 'Actors' within a grid system. This was a natural fit for 'Pellet-Man' and is a good exercise for students to work on something exciting and challenging while reinforcing their new knowledge of inheritance and practice using the system found on their AP exam.
We introduced the project to the students blindly using the 'Project Yellow Sphere' video by James Farr. If you haven't seen it, watch it here:
Then of course, we told them they'd be writing their own implementation of the game.
Working with Brett Wortzman to create curriculum, we tasked the students with creating four Ghost actors and a Pellet-Man with the following criteria:
- Blinky – move forward until an intersection is reached, then turn in whichever direction is more towards Pellet-Man unless Pellet-Man is super powered, in which case turn away from Pellet-Man.
- Pinky – turn left if left is clear and move then move forward, otherwise move forward three times (or until a wall is hit)
- Inky – move forward until an intersection is reached, then turn left or right (picked at random). Continue turning in that direction until you can move forward again.
- Clyde – randomly choose to move forward (if able), turn left, or turn right (all with equal probability)
- Pellet-Man - any strategy
You can download the student resource package for this project. Simply add the pacgrid.jar and gridworld.jar packages to your Java classpath and implement the interfaces for the actors above. Javadoc is included.
Please let us know if you decide to use this project in a classroom environment.