3 ms·
I'm having a lot of fun with this. I'll submit something soon. You swallow all exceptions and make the robot guard instead. This is nice, but it makes it har
by Xephyrous 13y ago
I'm having a lot of fun with this. I'll submit something soon. You swallow all exceptions and make the robot guard instead. This is nice, but it makes it hard to develop, because you can't see what went wrong. Here's a way you can modify it to have your exception and eat it too:
from http://docs.python.org/2/library/traceback.html#traceback-examples http://docs.python.org/2/library/traceback.html#traceback-ex...
In game.py, at the top, put
import sys, traceback
and around line 285, replace this:
except Exception:
next_action = ['guard']
with this:
except Exception:
print "The robot at (%s, %s) raised an exception:" % robot.location
print '-'*60
traceback.print_exc(file=sys.stdout)
print '-'*60
next_action = ['guard']
That makes your robot a lot easier to debug. Awesome game, have you thought about putting it on github so people can submit patches?
- brandonhsiao 13y agoWow, great work. Mind if I steal this? And yeah, I'll open-source it pretty soon.
- Xephyrous 13y agoNot at all.