Exception in endTurn Method


#1

Hey,

my code throws a NullPointerException after executing System.out.println(); in the method endTurn in Game.java. Using remote debugger i checked and tried everything i know to find the error. Am i violating any rule? Might it be halite.exe? since exception breakpoints don’t catch it.

Thanks!


#2

it seems the game might get commands from output of the bot. When trying to print log statements they come out in the middle of other actions and then it breaks. last years bot i don’t think worked that way, but we may need to set up logging in some other way.


#3

i was able to log things like this.

private static void init(Game game, long rngSeed){
    logFile="map-" + rngSeed + ".log";
    outputBoard(game.gameMap.cells);
}

private static void log(String s){
    try {
        PrintWriter log = new PrintWriter(new FileOutputStream(new File(logFile),true));
        log.println(s);
        log.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

 private static void outputBoard(MapCell[][] map) {
    String rows = "";
    for (int i = 0; i < map.length; i++) {

        for (int j = 0; j < map[i].length; j++) {
            rows+=map[i][j].halite + "\t";
        }
        rows+="\n";
    }
    log(rows);
}
}

#4

Thanks!
i just rewrote a couple things and cleaned up my code, so it’s gone for now. If it returns i’ll try this!


#5

i’m kinda stupid there is also a log class in halite. can just use that will not show up in the terminal when running the game but will show up in the bots individual log.
Log.log("Successfully created bot! My Player ID is " + game.myId + ". Bot rng seed is " + rngSeed + ".");