In my code there are multiple packages and methods but I will try to keep it as simple as possible.
The grid and ant look like this:
// prints ant and board
System.out.print("+");
for (int j = 0; j < board.getWidth(); ++j) {
System.out.print("-");
}
System.out.println("+");
for (int i = 0; i < board.getHeight(); ++i) {
System.out.print("|");
for (int j = 0; j < board.getWidth(); ++j) {
if (i == ant.getIPos() && j == ant.getJPos()) {
switch (ant.getDirection()) {
case NORTH:
System.out.print("^");
break;
case SOUTH:
System.out.print("V");
break;
case EAST:
System.out.print(">");
break;
case WEST:
System.out.print("<");
break;
}
} else {
if (board.isWhite(i, j)) {
System.out.print(" ");
} else {
System.out.print("*");
}
}
}
System.out.println("|");
}
System.out.print("+");
for (int j = 0; j < board.getWidth(); ++j) {
System.out.print("-");
}
System.out.println("+");
I am using a class called execute step which makes the ant move in a certain direction. There is also a direction class called enum direction{ NORTH SOUTH EAST WEST}. Basically I want to know how to get the ant moving.I know that not many of you will understand this because I'm mainly appealing to those who have done the same thing before unless you want to challenge yourself. But please ask me if you want more information on the code, of course I can't post all of it due to it being in multiple packages.