Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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-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?


Wow, great work. Mind if I steal this? And yeah, I'll open-source it pretty soon.


Not at all.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: