https://towardsdev.com/how-i-built-my-first-serverless-robot-and-won-200-87127a0b108c Get started Open in app Towards Dev Sign in Get started 511 Followers * HomeWrite For Us About Get started Open in app How I built my first serverless robot and won $1000 Michele Curci Michele Curci Mar 13*6 min read I'm Michele, a computer scientist who works in the Big Data field. At the beginning of January 2021, through Linkedin, I became aware of the FaaS War global serverless competition. Passionate about video games since I was a child, I was attracted to the images of the 80s-style game and after a careful analysis of the rules of the game I started developing my own fighter. In this story I will focus solely on my development experience, on the choices and ideas that led me to the first round victory. I will briefly explain what Faas Wars is but for all the necessary information refer to the official website. [1] What is FaaS Wars? FaaS Wars is a programming competition organized by Nimbella and supported by several members of the Apache OpenWhisk community. The target of the competition is to approach the serverless world while having fun. The goal of the game is to defeat enemy robots developed by other participants in 1 on 1 battles. You can control your robot writing code to handle events and give orders. The interaction with the opposing fighter takes place through serverless events that we must manage in the best possible way to prevail over the opponent. The events are: * idle: when the robot is running out of commands and has nothing to do * enemy-spot: when the robot sees the enemy right in front of the turret * hit: when an enemy laser strikes the robot * wall-collide: when the robot hits the wall and cannot move forward anymore Based on the event received, it is necessary to react and give orders to the robot. The main orders are for moving the robot forward, backward, or rotating in place. Each main order can be accompanied by a secondary order to be executed in parallel, such as shooting or rotating the turret. 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. [1] 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. [1] [1] 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. [1] [1] 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: * January final battle * March final battle 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/ Michele Curci Follow 88 88 88 * Nimbella * Serverless * Faas * Robot * Programming More from Towards Dev A publication for sharing projects, ideas, codes, and new theories. Read more from Towards Dev More From Medium .NET Core 3.1 updates in Cloud Shell and App Engine flexible environment Mete Atamel in Google Cloud - Community [0] [0] Using OpenResty in enterprise grade environments Konstantin Ostrovsky [1] [1] Raspberry Pi 3 for the First Time Naoki [1] [1] The AWS Hangover Kevin J. Dolan in Metric Tech [1] [1] Running Kafka Consumer using GoLang Sachin Shukla in Deskera Engineering [1] [1] RISE OF THE TITAN Titan Finance [1] [1] Meet the new, enterprise-grade RPA Express 2.0 WorkFusion in WorkFusion [1] [1] How to: Work Item Visualization report in Power BI using OData to connect Azure DevOps Vinicius Moura [1] [1] About Write Help Legal Get the Medium app A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store