Giter VIP home page Giter VIP logo

elosensei's Introduction

Elo-sensei

A Discord bot implementing the Elo rating system for arbitrary games.

Elo-sensei is written in Python and is specifically designed for ranked MissileWars on CubeKrowd, but should also be able to accommodate other games.

Dependencies

  • Python >= 3.5
  • Discord.py >= 1.0.0
  • pandas

License

Elo-sensei is licensed under the GNU GPL v3.

Thanks

  • CubeKrowd's staff and players for hosting and maintaining the wonderful community that makes this possible
  • Ausxh/Kurusa for this idea
  • XNBlank for providing a great example of a simple, working discord bot
  • Rapptz and Discord for providing the platform to make this possible

elosensei's People

Contributors

chr1s-b avatar colin29 avatar lekro avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

colin29 drakan1

elosensei's Issues

Sanitize user ids

Currently we allow arbitrary user IDs to become players, by sending elo! match 1 win 2 loss. But this doesn't make sense in production. So this has to be disabled after testing.

Add score adjustment events and comment field

If we are unsure about part of the scoring history, we can add score adjustment events which explicitly set the score of a particular user id.

A comment field will allow us to store comments about matches and circumstances under which scoring adjustments occur. (e.g. "Migrate scores with unknown history")

Ensure there are no race conditions involving match_history and user_status

Currently, we are utilizing asyncio's locks to prevent race conditions in which two asynchronous operations access the match_history or user_status at the same time. However, these locks are currently in use for atomic actions only, while they should really be acquired for the entire duration of operations on the match history, until the entire operation is done and the match history or user status are in a valid state.

Add integer event IDs for convenience

It's easier to reference events by number. Though this number may not be unique if the system is restarted, attempting to reference by timestamp is annoying. It's also somewhat neat to see a #42 in the corner.

Serialization efficiency considerations

  • use categorical dtype for team status
  • use csv (good for text), cpickle or hdfstore. pickle seems like the best option for numbers, but is no longer human readable. Maybe normally save as pickle, but save as csv or json if a user-editable version is desired. msgpack also seems like a good option.
  • deserialization should produce the same df
  • When to serialize? after each operation? on shutdown? additionally serialize periodically?

Integrate with discord permission nodes

  • Require a particular rank/role/permission node to add matches/administrate
  • Restrict bot's replies to certain channels
  • This should be configurable
  • Nicely ask for permissions to change user's roles if that's configured
  • Think about configuration for roles (by name, by id?)

Recall players by id

Currently players can be recalled by mentions or beginning of name. Adding an option for recalling by id would allow for unambiguous addressing of players

Timezone support

Modify user inputs to prevent timezone issues that could result in creating matches out of order. Store timestamps in the database through one centralised timezone (something like UTC or GMT)

Update to discord.py 1.0.0

There are many breaking API changes in the new version, we need to address these and move to the new version of discord.py.

The new documentation is available here.

Add delta mask event

Current delta events are inline. This means they will affect ratings of players other than the one they are set on. Having a delta mask event would allow points added from achievements, removed by punishments, and other manual changes to remain neutral for Elo rating, but still reflect on the player's status.

TODO:

  • Add column for delta mask in the user status df
  • Add delta mask event, rename delta inline event to delta_inline
  • Add logic to update players using delta mask (only the delta_mask column is updated for users)
  • Add logic to show players' masked scores (this can just be a function get_masked_elo which first calls get_elo and then adds the mask)
  • Add logic to show both raw Elo rating and masked scores in the player cards
  • Top players by scores, or by rating? (or both)

Add edit command

elo edit EVENTID NEWEVENT

EVENTID can just be given a type hint of int.

Check if the match history contains an event with that event ID.. If not, throw an error.

Using the new EloEventConverter, parse NEWEVENT. The passed type should be the same as the old event. Remove the old event, and add the new one to the match history.
All old optional values should remain the same. (i.e. if any optional values are None after parsing NEWEVENT, get them from the old event.)

We need to make sure that the EloEventConverter isn't filling in default values for things like K factor.

After everything's done, recalculate elo.

Add moderation features (?)

From rules/punishments in discord:
This sort of thing should be configurable, and is definitely low priority. Since this will vary greatly per implementation of rules, it may be left up to admins to do this.

Level 1 Infraction
Results in a warning more often then not, some cases may lead to being muted. Repeated Level 1 Infractions will result in a Level 2 Punishment.
Level 2 Infraction
One warning, and one warning only, repeating a Level 2 Infraction results in getting the Benched role, which does not mute you, but it prevents you from playing any ranked games. You will have the Benched Role for a day. Repeated Level 2 Infractions will result in a Level 3 Punishment.
Level 3 Infraction
There are no warnings for a Level 3 Infraction, you will instantly get Benched for 3 days, and depending on the situation, you will be muted for one day. Repeated Level 3 Infractions will result in a Level 4 Punishment.
Level 4 Infraction
There are no warnings for a Level 4 Infraction, you will instantly get Benched for a week, and you will instantly get muted, despite the punishment, for 3 days. Upon returning, you will lose 150 elo. Repeated Level 4 Infractions will result in a ban.

Add delete command

elo delete EVENTID

Straightforward. Delete the event with that event id, and then recalculate elo.

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.