Giter Club home page Giter Club logo

accolade's Introduction

Accolade

A naive, stateless, ladder-like skill algorithm intended for use in foosball, but might also work for other games where two teams are opposed, such as Counter-Strike or table tennis.

Accolade is based on the following principles:

  • Fame is the currency in question.
  • Each players begins with a mediocre fame value (default initialFame: 50).
  • There is an absolute floor (default minFame: 1) and ceiling (default minFame: 100) fame value.
  • When competing, each participant bets a percentage of their fame (default betSizePercentage: 10).
  • Winners divide the pot, losers forfeit their fame.
  • A competitor with 1 fame can't go lower, and thereby risks nothing by competing. Likewise, a competitor with 100 fame can't go higher and can only hope to keep the same position.
  • If one winner can't receive all fame gained from a match, her team mates receive the overflow.
  • If none of the winners are able to absorb all the fame (due to maxed out values), the fame is transferred back to the loosers.

Usage

Accolade assumes the first team in the list (matchData.teams) are the winners and returns teams and players in the same order, with fame adjusted according to the internal algorithm.

npm install accolade
import Accolade from 'accolade'
const accolade = Accolade() // pass your own config object to override config/defaultConfig.js

const matchData = {
  teams: [
    [
      {id: 1, fame: 50},
      {id: 2, fame: 89}
    ],
    [
      {id: 3, fame: 71},
      {id: 4, fame: 40}
    ]
  ]
}
const match = accolade.createMatch(matchData)
match.quality() // get pre-match betSize for each player
match.rate() // calculate match result -> change in fame

License

MIT-licensed. See LICENSE.

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.