Skip to content

Instantly share code, notes, and snippets.

@dideler
Created March 30, 2012 22:43
Show Gist options
  • Save dideler/2256820 to your computer and use it in GitHub Desktop.
Save dideler/2256820 to your computer and use it in GitHub Desktop.
Chess club ranking system

The ranking system has two sections:

  1. Ladder rankings
  • player name
  • starting rank
  • current rank
  1. Statistics
  • player name
  • wins
  • ties
  • losses
  • win/draw/loss ratio

Could merge the two into one section.

Ladder rankings can be reset annually. The ladder rankings are relative. E.g. rank 1 means best player among other players

Rules:

  • No show (at weekly meetup): rank worsens by 1
    • rank = rank + 1
  • Starting ranks
    • starting rank of a new player is determined by order of joining club (next available empty rank)
    • after a ladder reset, initial ranks are randomly determined (gives worse players a chance to be at top)
  • Ties are possible in ladder rankings
  • Top 5 players can be officially challenged once per week by the same person
    • if challenged again same week, rankings and stats of both players not affected (i.e. fun game)
  • Fun games do not affect stats (wins/loss/ties) or rankings
  • Higher ranked player beats a lower ranked player in a ranked match:
    • stats get updated
    • ranking do not get updated
  • Lower ranked player beats a higher ranked player in a ranked match:
    • higher ranked player: rank worsens by 1
      • rank = rank + 1
    • lower ranked player: rank improves by half of rank difference
      • rank = rank - math.ceil((higher rank - lower rank) / 2)
  • Win/draw/loss ratio
    • ((wins + (draws / 2)) / (wins + draws + losses)) * 100
    • e.g. win:4, draw:10, loss:10 => (4 + 5) / 24 = 37.5%

Examples:

Example A: simple example to demonstrate lower ranked player beating a higher ranked player
----------
10: Jim
11: Bob

Bob beat Jim
Jim's new rank: 10 + 1 = 11
Bob's new rank: 11 - ceil((11 - 10) / 2) = 11 - 1 = 10

10: Bob
11: Jim

Example B: a more complicated example; should we allow ties?
----------
1: Alice
2: Bob
3: Chuck
4: Dave

Chuck beat Alice.
Alice's new rank: 1 + 1 = 2
Chuck's new rank: 3 - ceil((3-1)/2) = 3 - 1 = 2

now no one is ranked #1 or #3, we can either start rankings from first empty spot

1: Alice                           1: Alice
1: Bob     then Dave beats Chuck   1: Bob
1: Chuck   (using displayed rank)  2: Dave
4: Dave                            2: Chuck

or show actual rankings and hide empty rankings

2: Alice                           2: Alice
2: Bob     then Dave beats Chuck   2: Bob
2: Chuck                           3: Chuck
4: Dave                            3: Dave
5: Eve                             5: Eve

or show actual rankings and display empty rankings

1: -                               1: -
2: Alice, Bob, Chuck               2: Alice, Bob
3: -                               3: Chuck, Dave
4: Dave    then Dave beats Chuck   4: -
5: Eve                             5: Eve

Example C: same as B but no ties allowed
---------
1: Alice                     1: Chuck
2: Bob    Chuck beat Alice   2: Bob
3: Chuck                     3: Alice

this can get a lot more complicated, for example

1: Alice
2: Bob
3: Chuck
4: Dave

what are the rankings if Dave beats Alice?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment