FaaS Wars Season 2 - Step By Step Instructions
copied
FAAS Wars is a battle between robot fighters. You create a fighter by writing some code (as simple as a single function) and deploy the code as a serverless API using Nimbella.
Your function is the API. You do not worry about creating a server to run your fighter. With the Nimbella serverless cloud, you can focus on creating the best FAAS Fighter, and you won't be distracted by infrastructure concerns.
What can be better? Winning cash prizes!💰💰💰
Season 1 of FAAS Wars was a global success. We had 500 fighters from 7 countries compete and win $1,400 in prizes. You can read about the Season recap for more details.
We are back with Season 2 and new cash prizes. This time we partnered with HackerEarth and this season is all about team battles.
The details are available here.
Starter Fighter - build your first #ServerlessJedi
Check this repo you will find a starter fighter project which gets you going in less than a minute.
This project contains a serverless API that implements some basic FAAS Fighters. You can deploy these fighters to your Nimbella account and start battling.
Next, take it up a level by improving your algorithm. The winning fighter strategy last season was surprisingly simple in retrospect: scan back and forth along a particular axis, shooting lasers when you spot an enemy fighter, and only moving to evade their lasers when hit.
The input and output requirements for the API are described later on.
1. Install the Nimbella CLI
You will need the Nimbella CLI to get started. Please download the CLI specific for your platform from the Nimbella website and install it by following the prompts on your screen.
2. Login using the CLI
Once you install the CLI, run the following command on your terminal.
nim login
If you do not yet have an account, this will be your opportunity to sign up (it's free and no upfront information is needed except your e-mail or GitHub id). You do need a Nimbella account to keep going.
3. Clone and own your fighter
You will want to edit the implementations provided in the starter project. So clone the repo by running the following command.
git clone https://github.com/nimbella/faas-fighter.git
There are several sample fighters included as a reference. Each of the fighters is self-contained in a single source file. We provide reference implementations in JavaScript, Python and Go.
You can edit one of these or create your own using another language that you prefer. Use your favorite IDE to do the coding.
When you're ready, deploy the fighters to make your APIs live. This is done with the Nimbella CLI.
nim project deploy faas-fighter
The project deploy command assumes your project is called faas-fighter
and is in the working directory where you run the nim command from. You can specify the path to your project otherwise (e.g., nim project deploy /path/to/faas-fighter
).
The output from nim project deploy
is similar to the output below.
Deploying project '/path/to/faas-fighter'
to namespace 'example-namespace'
on host 'https://apigcp.nimbella.io'
Deployed actions ('nim action get <actionName> --url' for URL):
- GoBot
- JsBot
- PyBot
Understanding the Fighter API
You are creating a serverless API to implement the logic for your fighter.
- You may use JavaScript (Node.js or TypeScript), Python, Go, PHP, Java, Rust, Ruby, Deno, Swift, or .NET to implement your fighter.
- The API receives an Event as input and returns Commands as output.
- The fighter has an energy level that starts at a pre-determined level. The energy level decreases by one unit every time it is hit.
- A fighter is eliminated and the match is over when the energy level reaches 0.
- The match is also over (and your fighter is eliminated) if your API returns an error or throws an exception. Code carefully.
The Event
The fighter receive a message in the following format:
{
"event": "idle",
"energy": 5,
"x": 110,
"y": 240,
"angle": 23
"tank_angle": 232,
"turret_angle": 150,
"enemy_spot": {},
"data": {}
}
- The
event
can be:idle
: the fighter has its order queue empty and and asks for new ordersenemy-spot
: the fighter has spotted the enemy and can hit him firinghit
: the fighter was hit by an enemy bulletwall-collide
: the fighter collided with a wall
x
andy
are the position in the battlefield,tank_angle
andturret_angle
are the angles of the tank and of the turret in degrees.angle
is the sum of the angle of the turret and the tank, modulo 360energy
is your energy level,
When the event is enemy_spot
there is also the field enemy_spot
in this format:
{
"id": 1,
"x": 291,
"y": 180,
"angle": 23,
"distance": 202,
"energy": 1
}
The fields x
and y
are the enemy location, angle
is the absolute angle to fire him, distance
is its distance and energy
the enemy energy level.
The data field is a field that you can set with your own values with the data
command, to save a state for further actions.
The Commands
Your algorithm must decide on a set of commands to issue for your fighter. The result of the API is an array of commands (you can issue multiple orders). For example:
[{
"move_forwards": 50,
"shoot": true
},
{
"move_backwards": 50,
"turn_turret_right": 180,
"shoot": true
}]
Each command consists of a single sequential action and one or more parallel actions. The sequential actions move your fighter, the parallel actions aim the fighter's turret or perform other actions.
The sequential actions are:
move_forwads: <number>
: move forward of the given number of pixelsmove_backwards: <number>
: move backwards of the given number of pixelsmove_opposide: <number>
: move in the opposite direction of where you were moving - useful when you hit a wallturn_left: <number>
: turn the tanks to the left of the given angle in degreesturn_right: <number>
: turn the tanks to the right of the given angle in degrees
The parallel actions are:
turn_turret_left: <number>
: turn the turret to the left of the given angle in degreesturn_turret_right: <number>
: turn the turret to the right of the given angle in degreesshot: true
: fires a bullet; note you can fire up to 5 bullets at the same timeyell: <string>
: yell a message that will be displayed in the battle field
Each command should contain no more than one sequential action. If you specify more than one sequential action, only one will be executed (which one is executed is out of your control at that point).
You can read more about how to build a fighter following this tutorial.
Support and Feature Requests
We welcome your feedback and contributions.
- For general bugs and enhancements, we suggest opening an issue on GitHub.
- For quick questions, you can reach us in Slack.
- Nimbella joins DigitalOcean
- No infrastructure, just code. Learn the simplicity of serverless
- How to Migrate from Containers to Nimbella Serverless Architecture
- Kubernetes in simple words: explained by Eric Swildens
- How to optimize Kubernetes costs with Nimbella
- Step by step guide on how to port from AWS to Nimbella
- How to build and improve your serverless APIs
- Simplifying Kubernetes For Developers
- FaaS Wars Season 2 - Step By Step Instructions
- What is Nimbella and what does it offer?
- Results and Feedback of FaaS Wars - May the FaaS Be with You!
- 28 Serverless Gurus and experts One Must Follow in 2021
- The Faas Wars Alert!
- CI/CD pipeline with GitHub Actions
- How to deploy Node.js functions on Nimbella
- Kick-Start Your Serverless Journey
- AWS re:Invent Serverless Highlights
- Opportunities in the Wake of the AWS Juggernaut
- FaaS Wars: Serverless & Virtual Robot Competition
- #DeveloperIPL Online Hackathon Results & Feedback on Nimbella's Integration for Postman
- How to connect to the 3rd party database such as MySQL at Nimbella (example in Java)
- What can you do with the Nimbella Workbench?
- Deploy your Shopify Storefront to Nimbella
- Not All Serverless Platforms Are Created Equal
- Nimbella + Netlify: Uplevel Your Development Speed
- How we learned to Jamstack, Our Caputron story | Nimbella.com®
- Commander for Microsoft Teams - Your Custom Bot that runs on your Command!
- How to Build a Stateful Cloud App on Nimbella vs. AWS
- Starter Kit and Resources to Build a Serverless Cloud Application
- How to Build Serverless Slack Apps and Commands
- How to Set up your Serverless Environment and Get Started in Less than 2 Minutes!
- How to Quickly Deploy Stateful Serverless Apps with Nimbella?
- What is Serverless Computing? 3 reasons to start now
- How to Build a Serverless Slack App in Minutes.
- How to Manage your Netlify Website from Slack?
- How to Build a Serverless Slack Command in minutes
- How to Build a Stateful Serverless Cloud Web Application?
- How to Create an Optical Character Recognition (OCR) Application?
- Development at the Speed of Innovation – Nimbella, the Serverless Cloud
- Software Security Features on Enterprise Serverless Slack Apps Enabled by Nimbella Commander
- Coronathon India’s first demo day has 18 projects to help fight COVID-19
- See the time in different cities on Slack with Nimbella Commander
- Greet your friends in their native language in Slack with Nimbella Commander
- How to Fetch your Digital Ocean Billing Info on Slack?
- How to Stay Updated with Coronavirus Statistics on Slack?
- How to Fetch your AWS Billing Info on Slack?
- Get your Datadog billing info in Slack with Nimbella Commander
- Serverless Slack Apps and Slash Commands
- How to use Slack Effectively with Nimbella Commander?
- How to Create a multi-user Chatroom Hosted on Serverless Cloud?
- Using Docker actions, running Golang, and other fun things with OpenWhisk
- The duality between serverless functions and APIs
- Serverless HTTP handlers with OpenWhisk
- Serverless functions in your favorite language with OpenWhisk
- Run Swiftly: precompiled Swift actions
- Performance debugging for serverless functions using the Cloud Shell
- Locally debugging OpenWhisk actions
- Composing functions into applications
- A Serverless Composition of Functions
- The Serverless Contract
- The dawn of the Cloud Computer
- Security and Serverless Functions