0.01
Low commit activity in last 3 years
No release in over a year
Convert files of chess tournament data in different formats to ruby classes and vice-versa.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.4
~> 4.2
~> 3.12

Runtime

~> 2.0
~> 1.2
~> 1.1
~> 1.3, >= 1.3.2
 Project Readme

ICU Tournament¶ ↑

For reading or writing files of chess tournament data. Original project name on github was chess_icu.

Install¶ ↑

For Ruby 1.9.2, 1.9.3, 2.0.0, 2.2.1 (version 1.1.2 was the last compatible with Ruby 1.8.7).

gem install icu_tournament

For name canonicalisation, the icu_name gem is required and for handling SwissPerfect files the dbf and rubyzip gems are needed.

Usage¶ ↑

There are two main uses for this gem:

  • You have chess tournament data that needs to be written to a file in one of the supported formats. For example, your data is in a spreadsheet but you need it in Krause format so you can upload it to the FIDE rating server.

  • You have a file in a supported format and you need to extract the information it contains. For example, you have a Krause formatted file and want to extract the data and insert it into a database.

The currently supported formats are:

  • ICU::Tournament::Krause - the format used by FIDE.

  • ICU::Tournament::ForeignCSV - used by Irish players to report their individual results in foreign tournaments.

  • ICU::Tournament::SwissPerfect - often used by Irish tournament controllers to report results.

  • ICU::Tournament::SPExport - the SwissPerfect text export format.

Writing Files¶ ↑

Here’s how the 1972 Fischer-Spassky match could be formatted to Krause. First a tournament object is created and the players (just two in this case) are added with unique ID numbers. To keep the example short, not all the information that a Krause file might contain is included here (see ICU::Tournament::Krause for more details).

t = ICU::Tournament.new('World Championship', '1972-07-11')
t.add_player(ICU::Player.new('Robert J.', 'Fischer', 1))
t.add_player(ICU::Player.new('Boris V.', 'Spassky', 2))

Then the results for each round are added using the unique ID numbers to refer to the players.

t.add_result(ICU::Result.new(1, 1, 'L', :opponent => 2, :colour => 'B'))

Read this as: in round 1, player 1 lost against opponent 2 with the black pieces.

t.add_result(ICU::Result.new(2, 1, 'L', :opponent => 2, :colour => 'W', :rateable => false))

In round 2 player 1 lost by default against player 2. Similarly for all the other rounds:

t.add_result(ICU::Result.new(3, 1, 'W', :opponent => 2, :colour => 'B'))
# ...
t.add_result(ICU::Result.new(21, 1, 'W', :opponent => 2, :colour => 'B'))

Then finally, to create the file:

open('match.txt', 'w') { |f| f.puts @t.serialize('Krause') }

Reading Files¶ ↑

Suppose you have a tournament file in Krause format. Parse it into a tournament object like this:

data = open('tournament.txt') { |f| f.read }
parser = ICU::Tournament::Krause.new
tournament = parser.parse(data)

On success, the parse method returns an object of type ICU::Tournament. A tournament (ICU::Tournament) has two or more players (ICU::Player), and each player has one or more results (ICU::Result). See the rdoc for more details. You can traverse these objects and do what you want with them, such as storing the information in a database.

On error, the parse method returns nil and an error message can be retrieved from the parser (parser.error).

Author¶ ↑

Mark Orr, rating officer for the Irish Chess Union (ICU).

Current Maintainer¶ ↑

David Murray, rating officer for the Irish Chess Union. Contact ratings@icu.ie.