Live data from Hacker News

Show HN: Game where you write Python robots to fight other players

robotgame.org

51–60 of 102 posts

Re: Show HN: Game where you write Python robots to fight other players

#52
post #48

I am working on a marginally similar concept (interface in browser, battles on server) game, but I chose Lua as the scripting language since it is much easier to sandbox. I could not find an effective way to sandbox python for sure, and I am still not 100% on Lua.

Yeah, I considered Lua but I was stubbornly in love with Python. Judging by the responses on here, I seem to have made a mistake. Do you have a link to your project?

Why don't you white-list imports? Bare python is to my knowledge pretty safe. simply block all imports short of the ones you know wont cause a security risk.

edit: never mind, just read your security section. I obviously don't know python.

Re: Show HN: Game where you write Python robots to fight other players

#54

Looks fun, can't wait to get started. In your instructions, you said to run the program, call: python kit/run.py yourcode.py yourothercode.py --render If you try to run run.py from outside of its directory, it can't import settings.py Traceback (most recent call last): File "kit/run.py", line 1, in import game File "/home/ /robotgame/kit/game.py", line 30, in settings = SettingsDict('settings.py').d File "/home/ /rob…

Thanks for the tip. I updated the instructions.

Re: Show HN: Game where you write Python robots to fight other players

#55
post #35

So did anyone else ever play Core War back in the mid '80s? http://en.wikipedia.org/wiki/Core_War I wonder whether modern virtualization techniques are secure enough to allow you to provide unrestricted access to a virtualized OS and allow people complete access to fight for control?

yes, (early 90's for me), I wondered if anyone else remembered this. Also played another variant of this with a subset of C when at varsity.

Re: Show HN: Game where you write Python robots to fight other players

#56
I was looking through the code and saw someone submitted this but didn't run it:

    def x():
        g = yield
        yield g.gi_frame.f_back.f_back

    g = x()
    g.next()
    frame = g.send(g)

    player_id = frame.f_locals['player_id']
    globals = frame.f_back.f_globals

    CODE = """
    class Game:

        def _""" """_init_""" """_(self, *players):
            pass

        def run_turn(self):
            pass

        def get_game_history(self):
            return ''

        def get_scores(self):
            scores = [0, 0]
            scores[player_id] = 2000
            return scores
    """

    exec CODE

    globals["Game"] = Game
Clearly I have some security problems. Thanks to whoever made this for bringing this to my attention without actually screwing me.

Re: Show HN: Game where you write Python robots to fight other players

#57
post #55
post #35

So did anyone else ever play Core War back in the mid '80s? http://en.wikipedia.org/wiki/Core_War I wonder whether modern virtualization techniques are secure enough to allow you to provide unrestricted access to a virtualized OS and allow people complete access to fight for control?

yes, (early 90's for me), I wondered if anyone else remembered this. Also played another variant of this with a subset of C when at varsity.

In the mid or late nineties, I remember playing a game where you wrote autopilot and targeting code in C to control autonomous spaceships that fought against each other in an Asteroids-like 2D universe that ran as a distributed screensaver. It was mostly with people working at Canon Research here in Sydney, but I don't remember if they were the source/writers of it, or if they were just the social scene I discovered it through. (That's where I first learned about Kalmann Filters for predictive aiming, as being discussed in another HN frontage thread.)

Re: Show HN: Game where you write Python robots to fight other players

#59
Is there any way to access the map in the Robot class? For the default map, I can just hardcode it, but if you do intend for a robot to be playable on multiple maps, they'll need some way of knowing which squares are obstacles and spawn points. Without preserving state between turns, there's no way to figure that information out over time, either.

Re: Show HN: Game where you write Python robots to fight other players

#60
post #56

I was looking through the code and saw someone submitted this but didn't run it: def x(): g = yield yield g.gi_frame.f_back.f_back g = x() g.next() frame = g.send(g) player_id = frame.f_locals['player_id'] globals = frame.f_back.f_globals CODE = """ class Game: def _""" """_init_""" """_(self, *players): pass def run_turn(self): pass def get_game_history(self): return '' def get_scores(self): scores = [0, 0] scores[p…

As pointed out in another subthread, Python code is practically impossible to sandbox. Most competition isolate player code by running it in a separate process which has the additional benefit of easily allowing different implementation languages.

Making sure the process doesn't use your network to spread malware is not 100% trivial but still easier than sandboxing Python code within Python.

Good luck with your project!

Post reply on HN