Git Product home page Git Product logo

clashjs's Introduction

The idea is to create a battle game, where the participants code their AI, and then we make them fight! You can play by adding your own AI to the game!

How to run this project

Clone the repo, install dependencies, and start the game:

git clone https://github.com/stayradiated/clashjs
cd clashjs

npm ci
npm start

Then open http://localhost:3000 in your browser.

How to participate.

Add your player as specificed in player definition in

/src/Players/mybot.js

And then require yourself in

/src/Players.js

And run the demo again. Have fun!

Read the game definitions to learn how to create your player. Have fun!

Game. Functional Spec.

Introduction.

The game is simple: we will put all the players in a battle arena, and then make them fight to death. There will be ammo in the arena so they can shoot each other. The last player alive wins!

Game Rules.

  • Every player will have a position and direction on the grid. A player can not go over the grid limits, and can only face north, east, south or west.
  • The game will be turn based. Every turn we will excecute the AI of every player passing as arguments:
    • The state of the player.
    • The state of all other players.
    • A environment configuration option with:
      • Grid size.
      • The position of the ammo.
  • Every turn a player must execute some of the following actions:
    • Move one step in its current direction. (move).
    • Turn into any of the four directions. (north, east, south, west).
    • Shoot. (shoot).
  • A player can shoot to try to destroy another player.
  • A player can collect ammo in the moment it steps over it. A new ammo may appear in any moment of the game.

Game Definitions.

Player Definition.

Let the player definition (playerDefinition) be an object with the player info and its AI function.

export const info = {
  name: 'x-wing',
  style: 2 // one of the 6 styles (0 to 5)
}

export default function(player, enemies, map) {
  // think...
  return 'move';
}

The AI function will receive:

  • player
  • enemies (array of all the other players state)
  • and map

as arguments, and must return one of the following strings:

  • "north", "east", "south" or "west": To turn to that direction.
  • "move": To move one tile in the current direction.
  • "shoot": To shoot if the user has enough ammo.

Any other response, trying to move outside the arena size (map.gridSize) or trying to shoot without ammo, will result in a no-op.

Player State.

Let the player state (player) be an object with a player information like the following:

{
  position: `[<number>, <number>]`,
  direction: `<string>`, // One of 'north', 'east', 'south' or 'west'
  ammo: `<number>`,
  isAlive: `<bool>`
}

Game Map.

Let the game map (map) be an object like the following:

{
  gridSize: [<number>, <number>],
  ammoPosition: <array of [<number>, <number>] arrays>
}

clashjs's People

Contributors

matt-in-a-hat avatar

Stargazers

Kevin Isom avatar

Watchers

James Cloos avatar

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.