The GridWorld Case Study – A Great Teaching Tool

This post is a recap of an article I wrote for the CSTA Voice a year or two back explaining how I use the GridWorld Case Study in my AP Computer Science classes from day one.

The AP Computer Science GridWorld case study provides a tool that teachers can and should use from day one to introduce new topics, enhance prior topics, provide a game programming platform, and engage students.

From the very first day, GridWorld can be used to demonstrate what an object is and how to call an object’s methods without ever forcing students to write a single line of code.  Due to GridWorld’s interactive nature, manipulating the world is as easy as a mouse-click, allowing students to quickly add objects to the world and call methods.  Students quickly learn and observe how methods affect the appearance and behavior of an object; thus, learning why methods are important and useful.

After learning to create and interact with objects, students learn to write basic code to create objects using Actor and Location classes.  As it takes very little code to do this, students are not overwhelmed and gain confidence quickly learning one skill at a time.  Students learn how to add actors to the world and how the location class is used to store the position of an actor.  Method calling and parameter passing comes naturally as the results are seen visually via the graphical nature of GridWorld.

Having the basics in place, Actor can be used to teach inheritance by a simple override of the act method.  Constructors and instance variables are not yet necessary which once again allows students to simply focus on mastering a single concept – inheritance.  Using inheritance, students can make new actors that move around the grid and explode when hitting an edge which is very entertaining and engaging.  Students learn how to use the fundamental actor methods and get more acquainted with the location class.

Once inheritance is down to an art, decision making can be introduced so that the actors no longer move and explode, but rather move across and reappear on the opposite side of the screen.  Students learn to use if statements to check boundaries and determine when to make the actor move so as not to collide with the edges.  This process is once again very visual and engaging and students really get into it.

At this point, Bug comes into play perfectly.  Bug has some new methods and it requires a fundamental understanding of inheritance and decision making.  Using Actor before Bug enables students to learn how a Bug is built before every seeing one.  Bug moves around the grid very much like the new Actors created in previous units.  Students find the movement and action of Bug pretty straight forward as the students have already made an Actor move and are also very comfortable with inheritance and method overriding.  The prep work has paid of big time as Bug is very easy to use and understand.

After using Bug and making Actors move, looping is pretty much ingrained as students have now been using the step button of world which continually calls the act method of each actor over and over again.  Students can now transition into writing loops and using loops to solve problems.  GridWorld can be used to teach for loops, while loops, and nested loops more easily as the graphical nature allows students to see the results of the looping.  Working with loops graphically helps students as they can see how the loop works.

Using GridWorld very early in the year enables student to gain a solid understanding of  basic object instantiation,  method calling, inheritance, and decision making while learning how to interact with a grid, properly use a location, create an actor, and interact with a world.  These are all very important skills that provide a great foundation for students in the AP Computer Science class.  The GridWorld case study provides a wonderful tool that can be used all year long to enhance the learning of all computer science students.

Once the foundation is built, lots of great game projects can be used to expand student knowledge and get students very excited about Computer Science.  Board games work very well with Gridworld and can be created with lots of interactivity.

More GridWorld Information