Leaderboard

As of v0.4, ChessCraft stores all game results (win/draw/lose) in a results database file. By default, this file is a SQLite v3 file in plugins/ChessCraft/data/results/gameresults.db, but saving to a MySQL database is also supported - see Database Support below for more information. ChessCraft supports multiple views on the results database, and there are two views currently implemented: ladder (default) and league.

Viewing the Leaderboard

You can use the /chess list top <N> <view-type> command for this. <N> is the number of players to show (default: 5). view-type can be either "ladder" or "league" (default: ladder).

Some examples

List the top 5 players on the ladder:

/chess list top

List the top 20 players on the ladder:

/chess list top 20

List the top 10 players in the league:

/chess list top 10 league

Ladder View

The ladder view uses an algorithm based on the Elo rating system, whereby stronger players gain fewer points for beating weaker players, and vice versa (and a player who only draws with a much weaker player will actually lose points). In the ChessCraft system, all new players start with 1,000 points (in tournament Chess, calculating a player's initial Elo rating is quite a bit more involved).

As players win or lose, their rating will climb or drop accordingly.

The initial rating for all players can be changed via the configuration file:

  • ladder.initial_position

League View

The league view uses a simple system where a win is worth 2 points, a draw is worth 1 point and a loss is worth 0 points. All players start at 0, and gain points for each win or draw.

The number of points gained for a win, draw or loss can be adjusted via the configuration file:

  • league.win_points
  • league.draw_points
  • league.loss_points

Database Support

By default, all game results are stored in the SQLite v3 database plugins/ChessCraft/data/results/gameresults.db (note that older ChessCraft versions used results.db - if ChessCraft finds that file, it will attempt to import the game results from there and then rename results.db to oldresults.db).

You can, if you wish, configure ChessCraft to store the results in a MySQL database. To do this, first set up a MySQL database and suitable user, e.g. with the following mysql commands:

mysql> create database chesscraft;
mysql> grant all privileges on chesscraft.* to 'chesscraft'@'%' identified by 'some-secure-password';

You may wish to use a more restrictive set of hosts than '%' - e.g. if your MySQL database is on the same host as your CraftBukkit server, than 'localhost' is sufficient. You may, of course, also wish to add access to a web server somewhere (which is the main reason for using MySQL here).

Choose a suitable user and password (default user & password are 'chesscraft', but you should change at least the password).

Now configure ChessCraft to use MySQL:

/chess set database.driver mysql
/chess set database.host <host-where-mysql-server-runs>
/chess set database.name <database-name-you-chose>
/chess set database.user <user-you-chose>
/chess set database.password <password-you-chose>

(Or edit config.yml directly, and then run /chess reload config)

You should now have a connection to the MySQL database. Try running /chess list top and check the console or server.log for error messages.

Database Schema

This is the SQL used to create the MySQL tables, which may be of use if you want to write some script (e.g. PHP) to display the leaderboard on a web page:

CREATE TABLE chesscraft_results (
  gameID INTEGER NOT NULL AUTO_INCREMENT,
  playerWhite VARCHAR(32) NOT NULL,
  playerBlack VARCHAR(32) NOT NULL,
  gameName VARCHAR(64) NOT NULL,
  startTime DATETIME NOT NULL,
  endTime DATETIME NOT NULL,
  result TEXT NOT NULL,
  pgnResult TEXT NOT NULL,
  PRIMARY KEY (gameID)
);

CREATE TABLE chesscraft_ladder (
  player VARCHAR(32) NOT NULL,
  score INTEGER NOT NULL,
  PRIMARY KEY (player)
);

CREATE TABLE chesscraft_league (
  player VARCHAR(32) NOT NULL,
  score INTEGER NOT NULL,
  PRIMARY KEY (player)
);

CREATE TABLE chesscraft_pgn (
  gameID INTEGER NOT NULL,
  pgnData TEXT NOT NULL,
  FOREIGN KEY (gameID) REFERENCES chesscraft_results(gameID) ON DELETE CASCADE
);

The "chesscraft_" prefix is dependent on the database.table_prefix Configuration setting.

The tables are used as follows:

  • chesscraft_results: there is one entry for each game played to completion. The fields should be mostly self-explanatory. The result field stores the ChessCraft game result as defined here, while the pgnResult field stores the PGN result, e.g. 1-0, 0-1, or 1/2-1/2.
  • chesscraft_league and chesscraft_ladder: these two tables store the current leaderboard as League and Ladder views respectively (see above).
  • chesscraft_pgn: there is one entry for each game, and the entry is linked to the corresponding chesscraft_results table via the gameID key field. The pgnData field stores the complete move history for the game in PGN format.

Comments

Posts Quoted:
Reply
Clear All Quotes