Live data from Hacker News

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

robotgame.org

31–40 of 102 posts

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

#31
post #26
post #11

Any suggestions for the language? The game and site are written in Python so that seemed most natural, plus it's a high-level language with a simple syntax. I could add more if people wanted though.

Maybe Lua would be a good candidate? From the usages I have seen of Lua, it could match the use case.

OP, if you do go with Lua, this sandbox seems to work when combined with ulimit: https://github.com/jnwhiteh/luasandbox

If you test on Mac OS, you should be aware that ulimit is not capable of limiting memory in Mac OS.

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

#32
post #18

Brandon - what methods are you using to run untrusted Python code in a secure sandbox?

Right now what I'm doing is: 1. search code for double underscores (to block magic methods) 2. replace `__builtins__` with a whitelisted version 3. hook `__import__` to only allow a whitelist 4. hook `getattr` to reject any key containing double underscores

Check out https://github.com/haypo/pysandbox/

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

#33
post #28

You need to say somewhere that: python kit/run.py yourcode.py yourothercode.py map.py --render is required to view the simulation. The "--render" argument doesn't seem to be mentioned anywhere on the site.

Right you are. Let me add that.

Slight bug, it treats param 3 as a map, so you can't put --render without the map.

You should also mention somewhere what no-standard libraries are needed (e.g. RestrictedPython). Maybe provide a requirements.txt

Otherwise, this is really cool. I especially love the game render. Great job!

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

#34
At Mixrank we've started doing mini-AI competitions. We'll have to try your game!

We've been doing Connect Four the last two weeks: https://github.com/smilliken/aigames/tree/master/connect-fou.... The runner is in Python, but you can write a bot in any language you like.

PS: if anyone wants to join, we're in San Francisco by the ballpark, and compete on Wednesday evenings.

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

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

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

#36
post #18

Brandon - what methods are you using to run untrusted Python code in a secure sandbox?

Right now what I'm doing is: 1. search code for double underscores (to block magic methods) 2. replace `__builtins__` with a whitelisted version 3. hook `__import__` to only allow a whitelist 4. hook `getattr` to reject any key containing double underscores

I would recommend looking at the PyPy sandbox environment as it is not possible to secure CPython in this way.

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

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

Not me, but I read about a contest that was similar to this. Unfortunately I can't find a link but the general idea was that people could write worms under a very small size limit and fight for control of memory much like this game.

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

#38
post #11

Any suggestions for the language? The game and site are written in Python so that seemed most natural, plus it's a high-level language with a simple syntax. I could add more if people wanted though.

It's a little obscure, but look at Embryo: http://docs.enlightenment.org/auto/embryo/

The interpreter was specifically designed with the assumption that Embryo scripts would come from untrusted sources. I believe that Enlightenment allows Embryo scripts to be embedded inside of theme files, for example.

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

#39
post #18

Brandon - what methods are you using to run untrusted Python code in a secure sandbox?

Right now what I'm doing is: 1. search code for double underscores (to block magic methods) 2. replace `__builtins__` with a whitelisted version 3. hook `__import__` to only allow a whitelist 4. hook `getattr` to reject any key containing double underscores

Is this python 2 or 3? Your description said that you didn't allow underscores, but if this is python 2, people would still be able to run threads (threads were renamed _thread in python 3).

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

#40

At Mixrank we've started doing mini-AI competitions. We'll have to try your game! We've been doing Connect Four the last two weeks: https://github.com/smilliken/aigames/tree/master/connect-fou... . The runner is in Python, but you can write a bot in any language you like. PS: if anyone wants to join, we're in San Francisco by the ballpark, and compete on Wednesday evenings.

It has been a lot of fun. Thanks for organizing it.
Post reply on HN