Halite Home

Bot sends an invalid character


#1

This is what comes up before it disappears half a second later. I can't figure out what is wrong with my code.

Then I receive this log:

--- Init ---
MyBot
--- Bot used 7 milliseconds ---


--- Frame #1 ---
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 30, Size: 30
--- Bot used 4 milliseconds ---
ERRORED!
Response received (if any):
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 30, Size: 30
--- Bot was killed. Below is the rest of its output (if any): ---
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at GameMap.getSite(GameMap.java:84)
at MyBot.main(MyBot.java:34)

--- End bot output ---

I have checked the 34th line in MyBot.java, but there are very similar lines right before it, and there's no error there. What's going on? If I need to provide more information let me know. Thanks!

Edit: I have checked with a friend and realised the problem. The variable I declared for the width and height was looking for the gameWidth which because it's an array, the last value is 1 more than what I was looking for. So it works now.


#2

Yes, that sounds like exactly your problem.