7 ms·
Code robots in Python. Fight other players. Climb to the top
- petercooper 13y agoThis isn't specifically about this implementation, but I've noticed perhaps almost ten similar projects (virtual, programmed PCROBOTS descendants) on HN over the past year. There seems to be a real interest in this area (I made one myself on a hack day a few years ago ;-)) but a lot of reinventing the wheel. Are there are any particularly popular open source projects of this sort that people interested in this area could perhaps collaborate around?
- ColinWright 13y agoThe C++Robots combat engine is available for download: https://news.ycombinator.com/item?id=6748373 https://news.ycombinator.com/item?id=6748373 http://www.gamerz.net/c++robots/ http://www.gamerz.net/c++robots/ http://www.gamerz.net/c++robots/c++robots.tar.gz http://www.gamerz.net/c++robots/c++robots.tar.gz
- jacques_chester 13y agoThe Urgame for this seems to be RobotWar: http://en.wikipedia.org/wiki/RobotWar http://en.wikipedia.org/wiki/RobotWar Which I'm aware of because it inspired Robot Battle: http://www.robotbattle.com/ http://www.robotbattle.com/ Which inspired RoboCode: http://robocode.sourceforge.net/ http://robocode.sourceforge.net/ Which seems to have inspired a lot of others. (Reads a bit like the Old Testament; all that begetting.) One problem is that almost all of them are language-specific. Robot Battle implemented its own language, RoboCode uses Java, this game is in Python. One game in the genre is RealTimeBattle, which instead allows bots to communicate with the game simulator via standard IPC. So, in theory, robot programs can be written in a variety of languages. http://realtimebattle.sourceforge.net/ http://realtimebattle.sourceforge.net/
- dserban 13y ago> "One problem is that almost all of them are language-specific." Shameless plug: I built a platform [0] like this - but language-agnostic - for use during hackathons at the local TU's department of CS / software engineering. By language-agnostic I mean both bots and engines can be written in any programming language one prefers, as long as that language can encode/decode JSON. Three game engines are ready, one more (called Trapdoor Reversi) is in the planning stages. I've already gotten enthusiastic feedback from a group of sophomores at a recent hackathon. If anyone finds it interesting, please star the repo. [0] https://github.com/rosedu/I.GameBot https://github.com/rosedu/I.GameBot
- xerophtye 13y agoHi! i actually built one too. But it was for a rather specific Competition at my university. the json idea is pretty cool. I built one in Java that ran the bot code as a process and used i/o redirection to talk to it. So the system had a client side program that would talk to the bot and a server side program that would arrange matches and maintain leaderboards etx
- pudquick 13y agoActually, the real original was a bit farther back - Darwin (which later inspired Core War): http://en.wikipedia.org/wiki/Darwin_(programming_game) http://en.wikipedia.org/wiki/Darwin_(programming_game) http://code.wikia.com/wiki/Core_War http://code.wikia.com/wiki/Core_War
- jacques_chester 13y agoI thought about mentioning CoreWar (I hadn't heard of Darwin, but that's pretty neat), but figured that it isn't really the same genre.
- mkramlich 13y agoThe ideal language-agnostic "robot wars" engine would prob involve just passing structured text messages over a socket via TCP. Then the robot's logic can be written in anything, as long as it could do sockets (which almost every language/stdlib/runtime/OS you care about can do already), and, could be running remotely or locally.
- Semiapies 13y agoI'm pretty sure there was one in the 90s that used just STDIN/STDOUT for cross-language competitions, but I don't remember the name...
- d23 13y agoYeah, but it doesn't really seem to fit this particular format, in that this one is sort of an "idempotent" method where you submit your code and the results are calculated deterministically by the server. The other way would require something to be compiled and run on the clients' individual machines. It'd be nice to not have to install any libraries or worry about connecting to a server at the "right" time.
- jacques_chester 13y agoDepending on the format, it's not idempotent. Most such games include some random elements, such as starting positions, "energy cookies" and so on. But you're right that a more agnostic system makes submission to a server trickier for the server.
- aymeric 13y agoI have open sourced terrarium.js: http://terrariumjs.wiselabs.net http://terrariumjs.wiselabs.net You program herbivores and carnivores and try to invade other people's terrariums. Your creatures can see, move, attack, defend, reproduce, eat.
- ColinWright 13y agoReminds me of the C++Robots "King of the Hill" competition: http://www.gamerz.net/c++robots/ http://www.gamerz.net/c++robots/ I've still got two robots in the top ten there, and another just outside.
- thejosh 13y agoDown now.
- yasyfm 13y agoLooks like it's back up!
- hkmurakami 13y agoprevious discussion thread (3 weeks ago) https://news.ycombinator.com/item?id=6656419 https://news.ycombinator.com/item?id=6656419
- hayksaakian 13y agoin this case, the author iterated significantly since the last post, now there's an online code editor, and it's easy to try out
- alexchamberlain 13y agoIt seems a large part of the previous discussion surrounded sandboxing Python; anyone know where the author is with that? I find it hard to believe it would be very hard if you just embed the players game in a C++ engine.
- brandonhsiao 13y agoWell, it turns out you can't sandbox Python at the language level. So now each user's code is run (a) in a separate process (b) in a chroot jail (c) as user nobody (d) with umask set to 0 (e) with a time limit of 300ms.
- krallin 13y agoI thought pypy had a sandboxed mode, did you get to experiment with it? if you did, what did you think?
- dbaupp 13y agoHave you experimented with using linux's cgroups for real security? (e.g. you can white/black-list specific syscalls, set time & memory limits etc, all at the kernel level) Example sandbox: https://github.com/thestinger/playpen https://github.com/thestinger/playpen
- jnbiche 13y agopypy has a fairly advanced sandbox, and as a side effect your code will probably run faster.
- brandonhsiao 13y agoAlso, with network connections firewalled via iptables.
- LoneWolf 13y agoMy first thought went to http://aichallenge.org/ http://aichallenge.org/ it's a shame there is still no new competition.
- brandonhsiao 13y agoI saw AI Challenge earlier! It looks really fun. I might steal one of their ideas and of put five or so teams of robots in a bigger map and see what happens.
- joosters 13y agoWhy python? The API could have been a simple textual one (or maybe JSON, or whatever) and piped to/from the robot programs. That way, robots could be written in whatever language the authors like. It would also help sandbox the robots from the game server.
- wiremine 13y agoMy guess is one of the project's goals it to reach programming. If that is the case, Python is a great language. If the goal was simply to make fighting robots, something more agnostic would be cool. That said, the system enforces a 300ms response time per robot, so compiled languages would have a big advantage.
- alexchamberlain 13y agoThis is how we should teach kids programming; the goal is simple, the API is simple and they can play against their friends... This has got me thinking...
- jlas 13y agoThe intro to programming class I took at CMU (Fall of '05) was pretty much this. We learned Java using a robot simulator. It was based on Karel the Robot, adapted for Java: http://www.amazon.com/Karel-Robot-Introduction-Object-Oriented-Programming/dp/0970579519/ http://www.amazon.com/Karel-Robot-Introduction-Object-Orient...
- jtfairbank 13y agoEvery year the UofI ACM puts on an AI programming game competition. I've competed and worked on the 2012 game, its a lot of fun. If you're a student or corp in the midwest, take a trip down in October. And the game is usually language agnostic. Did I mention there's also a whole conference with a bunch of tech talks, student parties, etc? https://en.wikipedia.org/wiki/MechMania https://en.wikipedia.org/wiki/MechMania
- matmann2001 13y agoI-L-L!
- ElongatedTowel 13y agoI always get a maximum recursion depth exceeded exception in game.py using the rgkit. The exceptions aren't very helpful and only point to problems in the runner, not the bot. I'm not even sure what is triggering it. The only rg method I'm using is locs_around.
- ElongatedTowel 13y agoSeems to happen whenever I use locs_around. I think I'll replace that method with my own. Half my robots are guarding because this function is hitting recursion limits every god damn time.
- brandonhsiao 13y agoSome other people have been having the same problem as well. If you can email your robot id to bh@brandonhsiao.com, I'll try to see what the matter is.
- phreeza 13y agoHeh this reminds me of a game I wrote a while back, also python: https://github.com/phreeza/cells https://github.com/phreeza/cells In fact I would guess the API is perhaps inspired by the cells API. Writing a web frontend is something I have been wanting to do for this a long time, nice to see someone implement that!
- pavel_lishin 13y agoI really wanted to play with that, but it ran far too slowly without PyGame, and I couldn't get PyGame to run on my mac, so I abandoned it :/
- phreeza 13y agoThats a shame, if I recall correctly for me it was trivial to set up with macports.
- Sami_Lehtinen 13y agoThis also quite interesting programming game, which allows several optimizations. http://aichallenge.org/ http://aichallenge.org/ I also used to play Omega Tank, but it wasn't as good as it could have been. https://en.wikipedia.org/wiki/Omega_%28video_game%29 https://en.wikipedia.org/wiki/Omega_%28video_game%29
- abus 13y agoPlease use <title> so I can tell the tabs apart.
- brandonhsiao 13y agoGood idea, thanks for the suggestion.
- imdsm 13y agoThis would be better if there were more in-depth docs. I want to know if my a bot is on my team? But how? Let's check the docs..oh wait..they're incomplete. Promising but not ready yet.
- brandonhsiao 13y agoYeah, I do need to make the docs friendlier. As for your question, though: if bot.player_id == self.player_id: # they're on your team!
- mabbo 13y agoNot sure what I'm doing wrong, but nearly every robot I write compiles, and then does nothing when run. The only time I got it to do something else was by taking the sample code, raw copy-pasting it in, and running that.
- QuasiAlon 13y agoAnybody aware of a similar game to ~teach~ python? I remember seeing a thread that used a war game to teach java, was hoping there's one for python too cheers
- monkeypizza 13y agohttp://www.hacker.org/bitbath/ http://www.hacker.org/bitbath/ is a really nice one in Java. And this one is ok, http://berlin-ai.com/ http://berlin-ai.com/ - you just provide the URL of your AI and they POST game states to you, and you have 5 seconds to reply with your orders.