public class Test { public static void main(String[] args) throws Exception { Field f; int delay=200; // time to sleep for if(args.length==0) // if no arguments are passed, use a default field, empty. f= new Field(20,20); else f=new FieldLoader().load(args[0]); if(args.length==2) // parse the step interval if present delay=Integer.parseInt(args[1]); // create the nodes. Node n1 = new TourController(f, new Point(1, 5)); Node n2 = new TourController(f, new Point(f.width()- 1, f.height()- 5)); char buf[][] = new char[f.width()][f.height()]; // count the number of steps and loop. for (int iterations=0;;++iterations) { // zero the output buffer for (int i = 0; i < f.width(); ++i) { for (int j = 0; j < f.height(); ++j) { buf[i][j] = f.get(new Point(i, j)).getrep(); } } // move the first node. n1.act(); Point p = n1.getPos(); buf[p.getX()][p.getY()] = '1'; // output // same for the second. n2.act(); p = n2.getPos(); buf[p.getX()][p.getY()] = '2'; // print a line, so we can tell where the top is.. for (int i = 0; i < f.width()+1; ++i) { System.out.append('-'); } System.out.append('\n'); // iterate in row-major order and output. for (int i = 0; i < f.height(); ++i) { System.out.append('|'); for (int j = 0; j < f.width(); ++j) { System.out.append(buf[j][i]); } System.out.append('\n'); } // see if they touch, and quit if so. if (n1.touches(n2)) { System.out.printf("They meet at %s, after %d steps\n", n1.getPos().toString(),iterations+1); break; } // pause for a bit. Thread.sleep(delay); } }}