Robocompo - Programming game
What is Robocompo, few words about Gamedev.pl
Robocompo - programming game
Script editor sandbox
I don't have any scientific fundamentals about AI, only few years of studying math and computer science in one of public universities in Warsaw. For me writing simple algorithms, which are supposed to immitate AI in some game, is a hobby. It's fun and very addictive. So why not share this passion with other people in competetive environment? That's where idea of Robocompo comes from.
My original plan was to make few games and let other people have fun programming AI script for them. That was very ambitious plan, because right now after 2 months there is still only one game available and it's RGBattle: Action RTS game. Three factions, 6 teams each, 6 units per team, each player controls one team. It's simple and it's fun.
- input - global variables: viewport(read only), status(read only), memory, teamMemory
- built in functions - rotate, move forward, shoot
- output - changes made to memory cells, executions of built in functions
You can implement pretty much everything in JS, there are no limits except one: your script can't execute asynchronously. It means that you can't launch threads etc.
It's very simple: each unit can move forward, rotate and launch missiles in their current direction at their enemies. So the objective is to hit as many enemies as possible and not die. There is collision detection, there are explosions, simple physics, friendly fire, units have limited health. For now it's very simple, but I still have plans to make some improvements, to make gameplay more rich.
How it works(client side)
Renderer is a mix of oldschool JS/CSS/HTML tricks and HTML5/Canvas animations. Every 5 seconds I fetch checkpoint file from server(below 100kb), which contains animation data split into 250ms intervals. Each cell contains information about some object i.e. position and velocity. Then all I need to do is interpolate between those values. It works great on client side and consumes close to none server resources.
Renderer performance is quite good, only limitation is lack of zoom in other browsers than Chrome. I have plan to make WebGL renderer, because that's the only way of breaking HTML5 Canvas limits(performance and rendering capabilities). I have some experience in using DirectX/OpenGL.
Skin editor, rankings, recent battles
I always wanted to build some distributed computing system and more or less Robocompo is such thing. AI scripts are executed in sandbox on dedicated server(s), each in separate JVM to avoid i.e. infite loop problem and also some security issues. While executions of scripts are distributed(I can configure as many nodes as I want), there is only one instance of battle simulator executed in it's own process. So far there was no need to summon more instances.
Most interesting thing about this project is the communicator layer. I serialize game data into file system every 5 seconds checkpoint of battle time. Then it's loaded by client and replayed in browser. I can lower the 5 seconds checkpoint limit to achieve real time experience. Battle simulator itself is very well optimized, but script execution time can be very random and that's the reason why Robocompo is not real time, however you can update you scripts during battle.
The data is a diff, text file, contains informations about object positions, movement/rotation vectors(and how they change over time) serialized every 250ms, so on the client side we interpolate between two states of game data. Every few seconds I serialize a "milestone", which contains full game data in order to prevent desynch.
Serialization is fast, files are lightweight(compressed file size is below 20kb), thanks to Apache HTTPd mod_mem_cache and linux disk buffer serving those files is done very fast. I didn't try to implement WebSockets yet, but it seems that I don't need them for this project.
It can be done much better
Browsers are the next gen platform for multiplayer games, so it's better to stick with JS on both sides in order to make things easier.
How to play RGBattle
- Register at Gamedev.pl
- Enter RGBattle
- Join competition
- Watch battle
- Update your script
- Go back to to p.4 and repeat
About this website
Gamedev.pl is polish indie gamedev community since 12 years already, now we got our interface translated to english language, so feel free to use it in comments and everywhere else on the website. It's still under construction and Robocompo project is it's most polished part.
I founded this website over 12 years ago, I am proffesional web developer since 2004, Gamedev.pl just like game programming is my hobby.27 april 2012