Stats4

Stats4

Source:
Version:
  • 2021/22
Author:
  • A. Freddie Page

Stats4 is a module to load and save game stats and Elo ratings for Connect 4 games.

Methods

(static) get_statistics(players) → {Object.<Stats4.Statistics>}

Source:
Parameters:
Name Type Description
players Array.<string>

A list of player names to return stats for.

Returns:

The statistics of the requested players as object with keys given in players.

Type
Object.<Stats4.Statistics>

(static) record_game(player_1, player_2, result) → {Object.<Stats4.Statistics>}

Source:

Record the result of a game and return updated statistcs.

Parameters:
Name Type Description
player_1 string

The name of player 1 (who plies first)

player_2 string

The name of player 2

result 0 | 1 | 2

The number of the player who won, or 0 for a draw.

Returns:

Returns statistics for player_1 and player_2, i.e. the result of Stats4.get_statistics([player_1, player_2])

Type
Object.<Stats4.Statistics>

Type Definitions

Statistics

Source:
Properties:
Name Type Description
elo number

The Elo score of the player. https://en.wikipedia.org/wiki/Elo_rating_system

player_1_wins number

How many times the player has won when playing first.

player_1_losses number

How many times the player has lost when playing first.

player_1_draws number

How many times the player has tied when playing first.

player_2_wins number

How many times the player has won when playing second.

player_2_losses number

How many times the player has lost when playing second.

player_2_draws number

How many times the player has tied when playing second.

current_streak number

The number of games the player has won since last losing (or ever if the player has never lost).

longest_streak number

The most consecutive games won.

Type:
  • Object