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.
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?
I wasn't born then, but me and my friends implemented a CoreWars 88' standard microprocessor in an FPGA for a school hardware project. It was possible to write code snippets in redcode and then we compiled it and sent it through usb and the FPGA was connected to a screen so we could see the progress.
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.
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:
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 <module>
import game
File "/home/<name>/robotgame/kit/game.py", line 30, in <module>
settings = SettingsDict('settings.py').d
File "/home/<name>/robotgame/kit/game.py", line 28, in __init__
self.d = AttrDict(ast.literal_eval(open('settings.py').read()))
IOError: [Errno 2] No such file or directory: 'settings.py'
So, has anyone compiled a list of these types of software?
Because it feels like there's some space for i) Something that can run on RPi for youth to learn programming and ii) a bi-monthly competition for HN, with rankings (most victories, smallest code with at least one win etc).
We still have bot challenges, and can easily host something like, with the added advantage of supporting a dozen other advantages, and a truck load of users.
I started my first match. The page were I'm taken keeps saying the match is running and hasn't finished yet. I don't see what could take so much, but it's ok. The problem is that if robot A is fighting against B, in A's profile it'll say it's lost against B, and in B's profile it'll say it's lost against A.
This is happening with all the robots in the warehouse, ("I", which is my robot, and the other two, who are fighting with each other).
I've been working on a similar concept off and on for a few years. To avoid all the security problems you're having, I've written a virtual machine that emulates a CPU and 64k of RAM. Instead of submitting code, you submit a 64k memory image of robot byte code.
Every turn of the game involves running a single cycle of the virtual CPU for every robot. Conceptually, the robots have radios and weapons that are controlled via memory-mapped IO in the virtual machine.
Things are slightly more complex than that because you don't want to give the first robot in the cycle an advantage (especially if they're firing lasers at each other), so you have to do each turn in multiple stages (run cycle, resolve real-world effects, update robot sensor state)
I'd LOVE to collaborate with a group of people to get something like this going because I think this would be a great way to introduce kids to programming at a machine level/electrical engineering. If anyone is interested, please send me an email. You can find my address in my profile.
That sounds like the much more fully developed version of what I have that I'd like to get to someday. I'm down for that collaboration thing. Let's get a group started.
The radios you mentioned are something I'd like to have someday. I think what makes games like these cool is the fact that your code controls an army of robots. It's more fun than just having two robots duel it out.
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.
Hey, I think something that would make the experience a lot better would be to incorporate Ace editor into it, so you get a very well-featured editor incase you don’t have easy access to a better-than-<textarea> editor.
Thanks for the idea! Yeah, I'm thinking it would be ideal if eventually there could be some kind of IDE on the site with simulator and all (like on fightcodegame.com).
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.
Sad, I spent two days writing a program I was sure to beat all the rest. Now I won't be able to run it :( Hope you fix the "gaping security holes" soon (whilst keeping the code Python-based), as seriously, I love Python.
Sorry, the games weren't being run for a bit. I was only catching security exception and one game threw some other exception, which crashed the whole process. I restarted it and now it should be working.
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.
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.
[+] [-] _g2lm|12 years ago|reply
[+] [-] praptak|12 years ago|reply
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!
[+] [-] sitkack|12 years ago|reply
[+] [-] Kiro|12 years ago|reply
[+] [-] nilkn|12 years ago|reply
http://robocode.sourceforge.net/
Because I had an amazing time in high school doing some local Robocode competitions. This could really bring some memories back.
Edit: Ahh, I see, it appears to be a sort of discrete turn-based version.
[+] [-] smilliken|12 years ago|reply
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.
[+] [-] kirubakaran|12 years ago|reply
[+] [-] bigiain|12 years ago|reply
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?
[+] [-] lawn|12 years ago|reply
I wasn't born then, but me and my friends implemented a CoreWars 88' standard microprocessor in an FPGA for a school hardware project. It was possible to write code snippets in redcode and then we compiled it and sent it through usb and the FPGA was connected to a screen so we could see the progress.
The source is fairly messy but have a peek if it interests you: https://github.com/treeman/MARC
[+] [-] blueblob|12 years ago|reply
[+] [-] lennel|12 years ago|reply
[+] [-] Ihmahr|12 years ago|reply
[1] http://robotgame.org/api
[+] [-] oneeyedpigeon|12 years ago|reply
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.
[+] [-] _g2lm|12 years ago|reply
[+] [-] Xephyrous|12 years ago|reply
from http://docs.python.org/2/library/traceback.html#traceback-ex...
In game.py, at the top, put
and around line 285, replace this: with this: That makes your robot a lot easier to debug. Awesome game, have you thought about putting it on github so people can submit patches?[+] [-] _g2lm|12 years ago|reply
[+] [-] benhamner|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
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
[+] [-] Xephyrous|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] pmiller2|12 years ago|reply
[+] [-] DanBC|12 years ago|reply
Because it feels like there's some space for i) Something that can run on RPi for youth to learn programming and ii) a bi-monthly competition for HN, with rankings (most victories, smallest code with at least one win etc).
[+] [-] fbnt|12 years ago|reply
[+] [-] bloometal|12 years ago|reply
Have you checked out https://www.hackerrank.com/ ? They initially started out with bot challenges as well.
[+] [-] anilgulecha|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] cosarara97|12 years ago|reply
[+] [-] cosarara97|12 years ago|reply
[+] [-] drblast|12 years ago|reply
Every turn of the game involves running a single cycle of the virtual CPU for every robot. Conceptually, the robots have radios and weapons that are controlled via memory-mapped IO in the virtual machine.
Things are slightly more complex than that because you don't want to give the first robot in the cycle an advantage (especially if they're firing lasers at each other), so you have to do each turn in multiple stages (run cycle, resolve real-world effects, update robot sensor state)
I'd LOVE to collaborate with a group of people to get something like this going because I think this would be a great way to introduce kids to programming at a machine level/electrical engineering. If anyone is interested, please send me an email. You can find my address in my profile.
[+] [-] _g2lm|12 years ago|reply
The radios you mentioned are something I'd like to have someday. I think what makes games like these cool is the fact that your code controls an army of robots. It's more fun than just having two robots duel it out.
[+] [-] gamegoblin|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
Do you have a link to your project?
[+] [-] L8D|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] Xephyrous|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] lemiffe|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] _g2lm|12 years ago|reply
[+] [-] wtracy|12 years ago|reply
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.
[+] [-] tarikjn|12 years ago|reply
[+] [-] code_duck|12 years ago|reply
[+] [-] asdddd333|12 years ago|reply
Why not expose a RESTful API and let people implement in whatever language they want and not have to worry about malicious code?