Coder Social home page Coder Social logo

moba-matching's Introduction

moba-matching

an system about matching players in an tradition MOBA game

传统moba游戏匹配系统

需求解析:

  • 一般来讲,moba中的匹配是根据匹配者的能力值(elo积分或者仅仅是玩家的星星数量),找到与其实力接近的玩家一起游戏.

实现分析:

  • 匹配者有两种匹配方式:单人匹配和多人组队匹配.
  • 无论是哪种方式,我们在匹配时仅仅需要两个信息:能力值和匹配人数.
  • 于是我封装了一个匹配者的信息类,称之:竞选者.文件位置:./lib/contestant.js
  • 当该系统的使用者需要将某个玩家或者队伍扔进匹配队列时,
  • 需先new一个contestant,给这个contestant分配一个唯一的id,一旦匹配成功,仅仅会以事件的方式,传出红蓝双方contestant.id的数组.
  • 使用者需监听该事件,拿到匹配成功的id们,之后使用者就可以随意的使用这些id们了.

系统简析:

  • 该系统会根据竞选者的人数,将竞选者放入单人/多人队列中,
  • 每matchingDelay毫秒会执行一轮匹配,每轮匹配最多产出maxProduction个匹配对.
  • 系统会优先从多人队列中选取匹配种子选手,且优先从多人队列中匹配(匹配出1组多人,数量不够从单人队列选取),人数正好为fighterNum时成功.
  • 对于竞选者来说,第一轮会根据自身能力值和允许范围值,在队列的0-maxSearch中匹配最优的玩家,若人数不足则在队尾等待下一轮.
  • 第二轮会放宽范围值到2倍,且临近原则,只要是在范围值以内的玩家,就可以匹配成功.且人数不足的时候会用机器人站位(机器人id统一为-1)

如何使用:

  • 请查阅实例代码:demo/test.js

初始化参数:

  • 参阅lib/constants中的ARGS

安装

npm install moba-matching

moba-matching's People

Contributors

luckyqqk avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  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.