npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moba-matching

v1.0.1

Published

an system about matching players in an tradition MOBA game

Downloads

8

Readme

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