Tuesday, September 25, 2012

How to Create an Unbounded Grid in GridWorld

You may find it convenient to change over from a simlple (bounded) grid to an unbounded grid to help you test your SpiralBug, etc. The way to do this is to add this 2nd line of code to the tester class right after you create the world:

ActorWorld world = new ActorWorld(); // this is the line of code you already have in your tester class
world.setGrid(new UnboundedGrid());  // this is the line of code you need to add

It will then be easier to see the spiraling patterns.

You will also need to add these import statements to the top of your code:


import info.gridworld.grid.*;
import info.gridworld.world.*;

Mr. Sarkar

3 comments: