Question: So I'm taking a crack on the Langton's Ant in Java but am running into a problem. I'm using a 2D array like this: int[][]
So I'm taking a crack on the Langton's Ant in Java but am running into a problem. I'm using a 2D array like this: int[][] 2D array= new int [5][5];
and have gotten to a point where I'm managing to count the steps the ant has taken as long as those parts of the array hasn't already been visited or as long as it's within the [5][5].
My issue is that I keep getting this error "Index 5 out of bounds for length 5" as well as "Index -1 out of bounds for length 5".and I'm not sure how to implement that the ant don't step outside the given array size.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
