Giter Site home page Giter Site logo

lambdasharp / lambdarobots Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 5.0 847 KB

Port of the old school C/Pascal Robots game to AWS serverless .NET

C# 40.46% Prolog 21.59% Pascal 32.17% CSS 0.41% HTML 1.06% JavaScript 4.03% Shell 0.28%
serverless game aws lambda lambdasharp

lambdarobots's Introduction

λ-Robots

In λ-Robots (pronounced Lambda Robots), you build a battle bot that participates on a square game field. Each turn, the server invokes your bot's Lambda function to get its action for the next turn until either your bot wins, is destroyed, or time runs out.

λ-Robots is a port of the 80s P-Robots game to AWS Serverless .NET using LambdaSharp.

Prerequisites

To get started, you must complete the followings steps.

  1. Create an AWS Account
  2. Install .NET 5 for LambdaSharp
  3. Setup LambdaSharp

Deploy the Game

Use LambdaSharp to deploy the LambdaRobots.Game module to your AWS account.

lash deploy LambdaRobots.Game:2.0@lambdasharp

This will create an S3 bucket for the game website, several Lambda functions for the game logic, and a DynamoDB table for the game state, as shown in this diagram. The battle bots can be deployed to any account, but must be in the same AWS region.

Architecture

Deploy the Battle Bots

λ-Robots includes three bots that can be deployed to try out the game and challenge your own bot.

Target Bot

Target Bot is a stationary bot that does not move or shoot. This bot is perfect target practice for other bots.

Build Configuration
Field Value
Name Target
Armor Medium
Engine Economy
Missile Dart
Radar Ultra Short Range

Deploy

lash deploy LambdaRobots.TargetBot:2.0@lambdasharp
Yosemite Sam Bot

Yosemite Sam Bot runs in random directions across the board, unloading its missiles as fast as it can. This bot does not aim and travels in straight lines from edge to edge.

Build Configuration
Field Value
Name Yosemite Sam
Armor Medium
Engine ExtraLarge
Missile Dart
Radar Mid Range

Deploy

lash deploy LambdaRobots.YosemiteSamBot:2.0@lambdasharp
HotShot Bot

HotShot Bot uses the Scan API to locate other bots before taking aim. It uses internal state to progressively refines its aim over time, making it very deadly to stationary targets. When HotShot is hit, it moves to a new random location to evade further damage.

Build Configuration
Field Value
Name HotShot
Armor Medium
Engine Compact
Missile Javelin
Radar Long Range

Deploy

lash deploy LambdaRobots.HotShotBot:2.0@lambdasharp

Starting the Game

Navigate to the URL shown at the end of the LambdaRobots.Game deployment. It will load the game configuration page where the ARNs for the battle bot can be entered. The same ARN can be used more than once as it represents a different instance of the same bot.

In this screenshot, the game is configured to initialize with 3 Target bots and 2 HotShot bots.

Game configuration

Click Start Game to initialize the bots and see the match unfold.

Game Play

Build Your Own Bot

To build your own battle bots, you need to complete the followings steps.

  1. Install .NET Core 3.1 for AWS Lambda Development
  2. Clone the LambdaRobots GitHub repository

To start, build and deploy the BringYourOwnBot module. Once deployed, verify that it initializes by pitting it against the HotShot bot. It shouldn't last long since it doesn't move or shoot.

Run the deploy command from the LambdaRobots checkout folder.

lash deploy BringYourOwnBot

Start by editing BringYourOwnBot/BotFunction/Function.cs and customize the Name of your bot.

Check out the LambdaRobots SDK documentation to learn about configuration options for your bot, actions it can respond with, and queries it can perform to find other bots.

Now update the behavior of BringYourOwnBot to shoot down the target bots. For example, you can use luck, like Yosemite Sam bot, which shoots in random directions, or targeting like HotShot bot. The latter uses the ScanAsync() method to find enemies and aim missiles at them. Remember that other bots may be out of radar range, requiring your bot to move periodically. Also, your bot can be damaged by its own missiles. Check GameSession.FarHitRange to make sure your target is beyond the damage range. If you don't mind a bit of self-inflicted pain, you can also use GameSession.NearHitRange or even GameSession.DirectHitRange instead.

Next update the behavior of BringYourOwnBot to avoid getting shot. For example, you can continuous motion, like Yosemite Sam bot, which zig-zags across the board, or reacting to damage like HotShot Bot. Beware that a bot cannot change heading without suddenly stopping if its speed exceeds Bot.MaxSpeed.

lambdarobots's People

Contributors

bjorg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

lambdarobots's Issues

Display robot build during match

It would be great to see what the build is for each robot during a match, in addition to the status information currently displayed.

Scoring System

Calculate winners in the game server instead of the front end.

Scan counter for robots

The robot statistics are missing a scan counter that shows how often a robot has scanned during a match. It would be very interesting to see how often a robot scans its surroundings during a match.

Remove Step Function implementation

The game engine has two implementation. One uses step functions, the other uses tail recursion. The step function implementation is about 150ms slower per turn than the tail recursion. To streamline the code, the step function version should be removed.

Show all status for all 7 robots during match

The start screen allows up to 7 robots to be added. However, the match display only has enough vertical room to show the status for the top 6. The 7th is only visible when scrolling down, which makes it impossible to see the status of all robots during the match.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.