Giter VIP home page Giter VIP logo

combat-service-ts's Introduction

Combat service

Simulates a combat game where the endpoint has to return the next target to attack.

Solution

A service which accepts an input JSON on HTTP, with the info about the battlefield and returns the next coordinate to attack.

The next target depends on the protocols that are passed to the request, they should be compatible between them. For example, closest-enemies and furthest-enemies protocols aren't.

Available protocols:

  • Prioritize closest enemy target 'closest-enemies'
  • Prioritize furthest enemy target 'furthest-enemies'
  • Prioritize allies targets 'assist-allies'
  • Don't attack any target with allies 'avoid-crossfire'
  • Attack a mech target. Otherwise attack another target 'prioritize-mech'
  • Don't attack mech targets 'avoid-mech'

It has a REST api under /targets resource accessible.

REST API endpoints:

 POST /targets/radar
   Accept: application/json
   Content-Type: application/json
   {
     "protocols":["avoid-mech"],
     "scan":[{"coordinates":{"x":0,"y":40},"enemies":{"type":"soldier","number":10}}]
   }

To run it locally:

  • Install dependencies npm install
  • Run like production npm run start
  • Run for dev (watches for any files changes) npm run dev
  • Go to http://localhost:3000/

To run with docker:

To run tests

  • After dependencies are installed
  • Run tests npm run test
  • Run tests watching for changes npm run test:watch
  • Run test with coverage npm run test:coverage

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.