zugzwang 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/lib/zugzwang.rb +17 -17
- data/lib/zugzwang/create.rb +10 -1
- data/lib/zugzwang/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c94a00ce313f8e6c8d11fbc4976ffd5d75d0d1ca2909bda1354c183fe0c4b448
|
4
|
+
data.tar.gz: cc8a44622f7a9005c9c8f9f80074fbb098c83566a0ad5f54a362b9cbf4c59661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400589fa148bff4060ae59f48a2f8d9e320a7afab5c5f261f6de703d57410cfe4084a78eaf8bf8562f31e67d515de59b2da0db6efe9583dea355f75a35277c52
|
7
|
+
data.tar.gz: a3926859051035f82a12c2c9770710a9be0b6a2342d8e570dbf1d9d57c6f467c02f918c3d780c81c0f851bd13b2922d5d1bafc9fa778fb893a18fb454cfb79e7
|
data/README.md
CHANGED
@@ -13,6 +13,8 @@ PGN (**P**ost-**G**ame **N**otation) files are plain-text files that provide rec
|
|
13
13
|
|
14
14
|
The extensive [game database provided by Lichess](https://database.lichess.org/) (over 368 million games as of July 2018) uses the following format for each game of within their PGN files.
|
15
15
|
|
16
|
+
This format is essentially the same as standard PGN formats, but with a few differences. Particularly with the game record and some of the metadata fields.
|
17
|
+
|
16
18
|
```
|
17
19
|
[Event "Rated Bullet tournament https://lichess.org/tournament/yc1WW2Ox"]
|
18
20
|
[Site "https://lichess.org/PpwPOZMq"]
|
@@ -65,11 +67,13 @@ In the example game above, the metadata section is the part that looks like:
|
|
65
67
|
|
66
68
|
This is the section that the CLI is concerned with, and will produce a database record with the fields consisting of the metadata for each game.
|
67
69
|
|
68
|
-
####
|
70
|
+
#### Game record
|
71
|
+
|
72
|
+
This section contains the actual record of the chess game, the moves are given in <a href="https://en.wikipedia.org/wiki/Algebraic_notation_(chess)">Algebraic Chess Notation</a>, along with the time on the clock for each move.
|
69
73
|
|
70
|
-
|
74
|
+
Additionally, some games may include Stockfish evaluation for each move.
|
71
75
|
|
72
|
-
In the example game above, the
|
76
|
+
In the example game above, the game record is the part that looks like:
|
73
77
|
|
74
78
|
```
|
75
79
|
1. e4 { [%eval 0.17] [%clk 0:00:30] } 1... c5 { [%eval 0.19] [%clk 0:00:30] }
|
@@ -82,6 +86,16 @@ In the example game above, the PGN section is the part that looks like:
|
|
82
86
|
|
83
87
|
Since this CLI is not concerned with individual moves or position analysis, this data is discarded during the parsing process.
|
84
88
|
|
89
|
+
## Field format changes
|
90
|
+
|
91
|
+
To fit with SQL data-type format specifications (and in order to optimize querying), the following PGN metadata fields have had their formats changed within the generated database file:
|
92
|
+
|
93
|
+
| Field | Format in PGN file | New format in database |
|
94
|
+
| ----------------- | ------------------------ | ------------------------------------------------ |
|
95
|
+
| `UTCDate` | `YYYY.MM.DD` | `YYYY-MM-DD` |
|
96
|
+
| `WhiteRatingDiff` | `+11` or `-11` (example) | `11` or `-11` (Integer without `+` for positive) |
|
97
|
+
| `BlackRatingDiff` | `+5` or `-5` (example) | `5` or `-5` (Integer without `+` for positive) |
|
98
|
+
|
85
99
|
## Installation
|
86
100
|
|
87
101
|
To install the CLI:
|
data/lib/zugzwang.rb
CHANGED
@@ -4,23 +4,23 @@ require "zugzwang/cli"
|
|
4
4
|
|
5
5
|
module Zugzwang
|
6
6
|
FIELDS = {
|
7
|
-
Event:
|
8
|
-
Site:
|
9
|
-
White:
|
10
|
-
Black:
|
11
|
-
Result:
|
12
|
-
UTCDate:
|
13
|
-
UTCTime:
|
14
|
-
WhiteElo:
|
15
|
-
BlackElo:
|
16
|
-
WhiteRatingDiff: {type: :
|
17
|
-
BlackRatingDiff: {type: :
|
18
|
-
WhiteTitle:
|
19
|
-
ECO:
|
20
|
-
Opening:
|
21
|
-
TimeControl:
|
22
|
-
Termination:
|
23
|
-
Variant:
|
7
|
+
Event: {type: :string},
|
8
|
+
Site: {type: :string, size: 50},
|
9
|
+
White: {type: :string, size: 30},
|
10
|
+
Black: {type: :string, size: 30},
|
11
|
+
Result: {type: :string, size: 10},
|
12
|
+
UTCDate: {type: :date, size: 15},
|
13
|
+
UTCTime: {type: :time, size: 8},
|
14
|
+
WhiteElo: {type: :integer},
|
15
|
+
BlackElo: {type: :integer},
|
16
|
+
WhiteRatingDiff: {type: :integer},
|
17
|
+
BlackRatingDiff: {type: :integer},
|
18
|
+
WhiteTitle: {type: :string, size: 5},
|
19
|
+
ECO: {type: :string, size: 3},
|
20
|
+
Opening: {type: :string},
|
21
|
+
TimeControl: {type: :string, size: 15},
|
22
|
+
Termination: {type: :string, size: 20},
|
23
|
+
Variant: {type: :string}
|
24
24
|
}
|
25
25
|
EXTENSIONS = %i[sql sqlite sqlite3 db]
|
26
26
|
end
|
data/lib/zugzwang/create.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'ruby-progressbar'
|
2
|
+
require 'date'
|
3
|
+
require 'time'
|
2
4
|
|
3
5
|
module Zugzwang
|
4
6
|
module Create
|
@@ -43,7 +45,14 @@ module Zugzwang
|
|
43
45
|
subbed = line.gsub(%r{[\r\n\[\]\"]},'')
|
44
46
|
field, value = subbed.split(' ', 2)
|
45
47
|
field = field.to_sym
|
46
|
-
|
48
|
+
if FIELDS[field]
|
49
|
+
record[field] = case FIELDS[field][:type]
|
50
|
+
when :string then value
|
51
|
+
when :integer then value.to_i
|
52
|
+
when :date then Date.parse(value)
|
53
|
+
when :time then value
|
54
|
+
end
|
55
|
+
end
|
47
56
|
prev = line
|
48
57
|
progress_bar.increment
|
49
58
|
end
|
data/lib/zugzwang/version.rb
CHANGED