Scores are fundamental to many competitive games. A two-player rock, paper, scissors game is normally scored with a simple tally of the wins. The scoring can be extended for a multi-player game to something more akin to a league.
Multi-player Scoring
The Advanced game allows more than two players and this means the draw can become more significant as a tie-breaker between players with the same number of wins. To recognise this, this version of the game uses a score of
- 2 for a win and
- 1 for a draw.
For comparison, some sports have moved to three points for a win system.
Score Table Presentation
The final scores are initially presented with the local player (yellow) at the top followed by the remote players (cyan) in the order in which they joined the game. CircuitPython has the sorted()
function and sort()
method from Python but for novelty, the scores are visually sorted with a bubble sort. The swapping of the elements is intentionally slow enough to be able to observe the algorithm at work. The video at the top of the page shows four players being sorted into descending score order.
The CircuitPython builtin sorts use the quicksort algorithm. As an O(n log n) algorithm, this is more efficient than the bubble sort's O(n2).
Text editor powered by tinymce.