ulope / planetwars-python-kit

An python interface to the second Google AI-Contest (PlanetWars) at http://ai-contest.com
16 stars 12 forks source link

Different game results depending on whether logging is ON or OFF #8

Open apinkin opened 14 years ago

apinkin commented 14 years ago

Hi Ulope, seeing some weird behavior which is reproducible consistently on two of my systems. Depending on whether logging is on (using --log option) I get different number of turns. I'm really puzzled what can be causing this. I don't have any random factor in my my bot's code, and sorted() in python is supposed to do stable sort.

  1. No logging

java -jar tools/PlayGame.jar maps/map1.txt 1000 200 log.txt "python MyBot.py" "python MyBot.py" ... Turn 143 Player 2 Wins!

  1. Player 2 logging ON

java -jar tools/PlayGame.jar maps/map1.txt 1000 200 log.txt "python MyBot.py" "python MyBot.py --log 2.log"

... Turn 132 Player 2 Wins!

  1. Both players logging ON

java -jar tools/PlayGame.jar maps/map1.txt 1000 200 log.txt "python MyBot.py --log 1.log" "python MyBot.py --log 2.log" ... Turn 140 Player 2 Wins!

Any ideas? Thanks in advance.

ulope commented 14 years ago

It may be possible that you are logging so much that in some rounds your bot is taking longer than 0.95 seconds to complete the turn and the automatic timeout protection is "kicking in". Check your log for "Bot failed to catch TimeIsUp exception" warnings. Also see the doc string of the Game class for more information on timeouts.

tedwards commented 14 years ago

I seem to be having an similar issue, only thing is, I loose if logging is turned off.

./playgame python_starter_package/maps/map$2.txt 1000 200 log.txt "java -jar python_starter_package/example_bots/$1.jar" "python planetwars-python-kit/MyBot.py " ... Turn 201 ... Player 1 Wins!

./playgame python_starter_package/maps/map$2.txt 1000 200 log.txt "java -jar python_starter_package/example_bots/$1.jar" "python planetwars-python-kit/MyBot.py -l foo.log --level DEBUG" ... Turn 97 ... Player 2 Wins!

I only have log.debug statement in my bot, so I thought, maybe I will try with INFO? ./playgame python_starter_package/maps/map$2.txt 1000 200 log.txt "java -jar python_starter_package/example_bots/$1.jar" "python planetwars-python-kit/MyBot.py -l foo.log --level INFO" ... Turn 97 ... Player 2 Wins!

And with ERROR ./playgame python_starter_package/maps/map$2.txt 1000 200 log.txt "java -jar python_starter_package/example_bots/$1.jar" "python planetwars-python-kit/MyBot.py -l foo.log --level ERROR" ... Turn 185 ... Player 2 Wins!

I will try to do some debugging later today.

apinkin commented 14 years ago

It turned out my bot was not fully deterministic since some of the sorts could return planets in different order. I had to modify the sorts to make sure they are always fully deterministic.

for instance,

my_nearest_planets = sorted(self.universe.my_planets, key=lambda p : p.distance(source_planet) + p.id/1000000.0)

tedwards, see if this fixes your problem as well.