How I built my first serverless robot and won $1000
By: Michele Curci
Tags: Nimbella, Serverless, Programming, Faas, Robot

My Experience

Guided by the official tutorial, I took my first steps by developing an elementary robot to understand and experiment with the mechanics of the game.

Then adopting an iterative design approach, the development process was quick and intriguing.

With each iteration, the strategy evolved, and the new robot prototype was immediately put to the test by competing against the other participants’ robots. It was precisely the skill of the opponents that allowed me to quickly design, improve and refine the winning strategy.

Battle in progress! (Cortex2 on left side)

I had noticed that most of the opponents had the same strategy: shoot on sight and rotate the turret to try to follow the movements. Excellent strategy, but the problem was that in doing this, they did not move much from their position and thus risked being hit easily.

Moving around on the map isn’t very fast unless you’re just moving back and forth. In fact, before being able to reach any point in the map, the robot must point in that direction, but the problem is that the rotation phase is slow, and therefore there is the risk of remaining too long under enemy fire.

So I had to find a way to move quickly and decided to take a cue from an old game created several years before I was born: Space Invaders.

Space Invaders screen, a 1978 arcade game

The idea was therefore simply to position the robot along an edge of the map and move only in two directions: above and below. Meanwhile, shoot as much as possible with the turret rotated towards the opposite edge hoping to hit the opponent in the center of the map.

This strategy brings several advantages because the robot never stays in the same position, so it is more difficult to be spotted and above all, it does not waste time for rotations.

Over time I have added new features and tried to improve the weak points. For example, I have improved the initial phase in which the robot moves from the initial position to the nearest edge, which is a very delicate phase because if it fails, it leads to a sure defeat. I added an action history to keep track of the latest events, in this way, for example, after spotting the opponent, I can move on his axis and follow him instead of moving randomly.

After implementing the main features, I submitted the robot called Cortex2 just in time for the last round in January and qualified for the final.

In the development phase, during the tests against the winners of the other rounds, I realized that I could play for the podium, but the outcome of the battles depended a lot on the starting position of the robots (which is random).

The final, viewable here, was fought by the winners of each round, in total 7, with a round-robin format in which each fighter would fight only one battle against each opponent.

With great surprise, I managed to win 5 out of 6 battles and thus won the first round of FaaS Wars!

Tips on how to win the FaaS Wars

The perfect strategy does not exist, so the goal is to develop a bot that on average manages to win against most opponents. For this purpose, it is advisable to analyze the behavior of the opposing robots and find some heuristics to follow.

Here are my tips for a good robot:

Move as much as possible and do not return to the same spot after a short time. Otherwise, if the opponent has spotted you, you risk being hit several times easily

Minimize the number and angle of rotations because they take time, and you can be spotted more easily

The information acquired during the battle is precious, keep it and look for a good strategy to exploit it

Keep track of the opponent’s movements so that you can predict the next ones

The rotation of the turret does not hinder the movements of the robot because it occurs in parallel, so try to always point it towards the opponent

Don’t forget to manage the collision with the walls otherwise, you could get stuck

Conclusion

Personally, it was a fun, creative and instructive experience. The development phase turned out to be simple and intuitive, enriched by the spirit of competition with the other participants.

It was also interesting to observe the ideas of other developers from all over the world.

Thanks to this event, I had the opportunity to get closer to the cloud computing concepts I had only heard about and in particular to the FaaS (Function as a service) category.

I completed the first season of FaaS Wars by winning the January prize of $200 and the March big prize of $800.

You can watch the finals at the following links:

I invite everyone to join the battle as there is yet the final battle of season 2 to run with 800$ to wind.

https://www.hackerearth.com/challenges/hackathon/faas-wars-season-2/