Run code after game finishes


#1

I’m trying to rig my game to log data after each turn. The only problem is that after sending the commands for the last move the games is killed. I can’t even seem to log anything in the caught EOFError exception in common.py. Anyone got any ideas?

At the moment, I’m leaning toward just doing all the halite collected/cost maths myself so I don’t need the same to finish, but that just complicates things more…


#2

Detect last turn and flush log. Something like:

game.turn_number == const.MAX_TURNS (or MAX_TURNS - 1)

#3

Won’t this trigger when I’m playing my last move? Not when I’ve finished playing it?


#4

Yes. After you finished playing your bot got SIGTERM (or other terminate signal, doesn’t tested it) so you can not do anything.


#5

Shame there isn’t some kind of cooldown period in the local client to allow for logging of final game state!


#6

#7

Your cooldown period is up to 2s in the last turn before sending the final move. :innocent: