JSRobots Programming Game

TLDR: link (In mobile the interface is awful, but it’s your life)

I was at my company gathering the other day and I ended up chatting with a colleague, let’s call him Alberto, who has a young son. We were discussing that he would like to get his son interested in programming, and since I’ve also developed the passion for programming and computer science at a quite young age, he was asking for advice.

So I was trying to remember how I got interested in programming, and I have no answer for this, I guess it was a combination of my father introducing to it and me discovering the power to control this mistical thing that was the computer at the time, not obiquitous like they are now, with smartphones, smart devices and so on. But still, I think the my interest was very much related to the fact that programming gives you very powerful building tools to unleash your imagination. It’s like Lego, but you don’t have to ask your parents to buy you the new set to have more pieces, all the pieces are already there, you just have to discover them. In fact, this is the hard part: discover the tools and how to use them is the key. This can be a tedious and long process, and it’s difficult to focus for this much time especially at young age, you really just want to “play”.

But sometimes you find some ways to bridge the gap and that lets you have some quick results. After having a way to easily see how you can affect a digital world, here’s where you understand if you like programming or not. And I loved it.

So, back to me at a young age, I remember at some point, probably around 13 years old or so, already admittingly quite deep into the computer science world (I had already some little programming projects ongoing) I discovered a programming game called JRobots. It was inspired (actually more than that, almost only a Java port of that) by a much older game called CRobots (written in C). It’s a simple game in which you can program your bot to fight against others in an arena, defining its behaviour by coding its “brain”, which takes decisions on how to act at every time step.

But the JRobots game still had a lot of overhead to get started, install and setup the JVM, download the source, make it run correctly, download other people’s bots and make them run along with the rest. I was lucky to have the knowledge to do it, and spent some months playing with this game, learning trigonometry and implementing new ideas (algorithms) like no school teacher could have done, in a very funny way.

So, here you have JSRobots, a JS rewrite of the thing. As in JRobots, in this programming game you have to write some code to control the behaviour of your “robot”, which is then placed in an arena to combat with another bot (possibly written by someone else). I think this is a nice way to get closer to programming because with very few lines of code you can see the differences of behaviour of your robot, and you can iteratively make it better and see its improvements and fails. Behing written in JS and running entirely in the browser, this is a zero overhead way to start writing some code. You start with the given example, you try to change it, press one button and the code is executing, showing your impact in this digital world.

Current state of the project is it’s a proof of concept, and can be improved in many ways. Has no server side logic, I could add some to be able to submit your bot for others to play against, but I have to take into account some security concerns before implementing that. For the rest, It’s missing some debug options for sure, but it’s usable.

The rules and documentation for the game are provided on the website itself (thanks to chatGPT again, if it’s not clear enough complain to openAI) and if you wish to send me your bot to be added to the list of opponents please do. You can find one of my emails somewhere in this blog or in the internet or at nicassio.it/daniele

The code is also on github