VreVre commited on
Commit
0d34d12
·
verified ·
1 Parent(s): 930ecf4

Chess Challenge submission by VreVre

Browse files
Files changed (7) hide show
  1. README.md +26 -0
  2. config.json +20 -0
  3. model.safetensors +3 -0
  4. special_tokens_map.json +6 -0
  5. tokenizer.py +491 -0
  6. tokenizer_config.json +50 -0
  7. vocab.json +78 -0
README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - chess
5
+ - llm-course
6
+ - chess-challenge
7
+ license: mit
8
+ ---
9
+
10
+ # chess_vre_3
11
+
12
+ Chess model submitted to the LLM Course Chess Challenge.
13
+
14
+ ## Submission Info
15
+
16
+ - **Submitted by**: [VreVre](https://huggingface.co/VreVre)
17
+ - **Parameters**: 974,004
18
+ - **Organization**: LLM-course
19
+
20
+ ## Model Details
21
+
22
+ - **Architecture**: Chess Transformer (GPT-style)
23
+ - **Vocab size**: 77
24
+ - **Embedding dim**: 92
25
+ - **Layers**: 11
26
+ - **Heads**: 4
config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ChessForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "dropout": 0.1,
7
+ "dtype": "float32",
8
+ "eos_token_id": 2,
9
+ "layer_norm_epsilon": 1e-05,
10
+ "model_type": "chess_transformer",
11
+ "n_ctx": 256,
12
+ "n_embd": 92,
13
+ "n_head": 4,
14
+ "n_inner": 276,
15
+ "n_layer": 11,
16
+ "pad_token_id": 0,
17
+ "tie_weights": true,
18
+ "transformers_version": "4.57.6",
19
+ "vocab_size": 77
20
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a76df446c01f8fdb2db8c3de97abfd36cc9fab6136285ec63562f21b9df254b
3
+ size 3907440
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[BOS]",
3
+ "eos_token": "[EOS]",
4
+ "pad_token": "[PAD]",
5
+ "unk_token": "[UNK]"
6
+ }
tokenizer.py ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Custom Chess Tokenizer for the Chess Challenge.
3
+
4
+ This tokenizer treats each move as a single token using the extended UCI notation
5
+ from the Lichess dataset (e.g., WPe2e4, BNg8f6).
6
+
7
+ The dataset format uses:
8
+ - W/B prefix for White/Black
9
+ - Piece letter: P=Pawn, N=Knight, B=Bishop, R=Rook, Q=Queen, K=King
10
+ - Source and destination squares (e.g., e2e4)
11
+ - Special suffixes: (x)=capture, (+)=check, (+*)=checkmate, (o)/(O)=castling
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import os
18
+ from pathlib import Path
19
+ from typing import Dict, List, Optional
20
+
21
+ from transformers import PreTrainedTokenizer
22
+
23
+ import re
24
+
25
+ class ChessTokenizer(PreTrainedTokenizer):
26
+ """
27
+ A custom tokenizer for chess moves using extended UCI notation.
28
+
29
+ This tokenizer maps each possible chess move to a unique token ID.
30
+ The vocabulary is built from the training dataset to ensure all moves
31
+ encountered during training have a corresponding token.
32
+
33
+ Example:
34
+ >>> tokenizer = ChessTokenizer()
35
+ >>> tokenizer.encode("WPe2e4 BPe7e5")
36
+ [1, 42, 87, 2] # [BOS, e2e4, e7e5, EOS]
37
+ """
38
+
39
+ model_input_names = ["input_ids", "attention_mask"]
40
+ vocab_files_names = {"vocab_file": "vocab.json"}
41
+
42
+ # Special tokens
43
+ PAD_TOKEN = "[PAD]"
44
+ BOS_TOKEN = "[BOS]"
45
+ EOS_TOKEN = "[EOS]"
46
+ UNK_TOKEN = "[UNK]"
47
+ EOM_TOKEN = "EOM" # End of Move token
48
+
49
+ MOVE_REGEX = re.compile(
50
+ r"""
51
+ (?P<color>[WB])
52
+ (?P<piece>[PNBRQK])
53
+ (?P<from>[a-h][1-8])
54
+ (?P<capture>x)?
55
+ (?P<to>[a-h][1-8])
56
+ (?P<promotion>[QRBN])?
57
+ (?P<check>[+#])?
58
+ """,
59
+ re.VERBOSE,
60
+ )
61
+ def __init__(
62
+ self,
63
+ vocab_file: Optional[str] = None,
64
+ vocab: Optional[Dict[str, int]] = None,
65
+ **kwargs,
66
+ ):
67
+ """
68
+ Initialize the chess tokenizer.
69
+
70
+ Args:
71
+ vocab_file: Path to a JSON file containing the vocabulary mapping.
72
+ vocab: Dictionary mapping tokens to IDs (alternative to vocab_file).
73
+ **kwargs: Additional arguments passed to PreTrainedTokenizer.
74
+ """
75
+ # Initialize special tokens
76
+ self._pad_token = self.PAD_TOKEN
77
+ self._bos_token = self.BOS_TOKEN
78
+ self._eos_token = self.EOS_TOKEN
79
+ self._unk_token = self.UNK_TOKEN
80
+
81
+
82
+ # Remove any duplicate special-token entries passed through kwargs
83
+ # to avoid "multiple values for keyword" errors when loading from disk.
84
+ kwargs.pop("pad_token", None)
85
+ kwargs.pop("bos_token", None)
86
+ kwargs.pop("eos_token", None)
87
+ kwargs.pop("unk_token", None)
88
+
89
+ # Load or create vocabulary
90
+ if vocab is not None:
91
+ self._vocab = vocab
92
+ elif vocab_file is not None and os.path.exists(vocab_file):
93
+ with open(vocab_file, "r", encoding="utf-8") as f:
94
+ self._vocab = json.load(f)
95
+ else:
96
+ # Create a minimal vocabulary with just special tokens
97
+ # The full vocabulary should be built from the dataset
98
+ self._vocab = self._create_default_vocab()
99
+
100
+ # Create reverse mapping
101
+ self._ids_to_tokens = {v: k for k, v in self._vocab.items()}
102
+
103
+ # Call parent init AFTER setting up vocab
104
+ super().__init__(
105
+ pad_token=self._pad_token,
106
+ bos_token=self._bos_token,
107
+ eos_token=self._eos_token,
108
+ unk_token=self._unk_token,
109
+ **kwargs,
110
+ )
111
+
112
+ def _create_default_vocab(self) -> Dict[str, int]:
113
+ """
114
+ Create a minimal default vocabulary with just special tokens.
115
+
116
+ For the full vocabulary, use `build_vocab_from_dataset()`.
117
+ This minimal vocab is just a placeholder - you should build from data.
118
+ """
119
+ special_tokens = [self.PAD_TOKEN, self.BOS_TOKEN, self.EOS_TOKEN, self.UNK_TOKEN]
120
+ vocab = {token: idx for idx, token in enumerate(special_tokens)}
121
+ return vocab
122
+
123
+ @classmethod
124
+ def build_vocab_from_iterator(
125
+ cls,
126
+ iterator,
127
+ min_frequency: int = 1,
128
+ ) -> "ChessTokenizer":
129
+ """
130
+ Build a tokenizer vocabulary from an iterator of game strings.
131
+
132
+ Args:
133
+ iterator: An iterator yielding game strings (space-separated moves).
134
+ min_frequency: Minimum frequency for a token to be included.
135
+
136
+ Returns:
137
+ A ChessTokenizer with the built vocabulary.
138
+ """
139
+ from collections import Counter
140
+
141
+ token_counts = Counter()
142
+
143
+ for game in iterator:
144
+ moves = game.strip().split()
145
+ token_counts.update(moves)
146
+
147
+ # Filter by frequency
148
+ tokens = [
149
+ token for token, count in token_counts.items()
150
+ if count >= min_frequency
151
+ ]
152
+
153
+ # Sort for reproducibility
154
+ tokens = sorted(tokens)
155
+
156
+ # Build vocabulary
157
+ special_tokens = [cls.PAD_TOKEN, cls.BOS_TOKEN, cls.EOS_TOKEN, cls.UNK_TOKEN]
158
+ vocab = {token: idx for idx, token in enumerate(special_tokens + tokens)}
159
+
160
+ return cls(vocab=vocab)
161
+
162
+
163
+ @classmethod
164
+ def build_vocab_from_iterator_bis(
165
+ cls,
166
+ iterator,
167
+ min_frequency: int = 1,
168
+ ) -> "ChessTokenizer":
169
+ from collections import Counter
170
+ import re
171
+
172
+ MOVE_REGEX = re.compile(
173
+ r"""
174
+ (?P<color>[WB])
175
+ (?P<piece>[PNBRQK])
176
+ (?P<from>[a-h][1-8])
177
+ (?P<capture>x)?
178
+ (?P<to>[a-h][1-8])
179
+ (?P<promotion>[QRBN])?
180
+ (?P<check>[+#])?
181
+ """,
182
+ re.VERBOSE,
183
+ )
184
+
185
+ token_counts = Counter()
186
+
187
+ for game in iterator:
188
+ moves = game.strip().split()
189
+
190
+ for move in moves:
191
+ # --- Castling ---
192
+ if move in ("WKe1g1", "BKe8g8"):
193
+ token_counts.update(["W", "K", "CASTLE_K"])
194
+ continue
195
+
196
+ if move in ("WKe1c1", "BKe8c8"):
197
+ token_counts.update(["W", "K", "CASTLE_Q"])
198
+ continue
199
+
200
+ m = MOVE_REGEX.fullmatch(move)
201
+ if not m:
202
+ token_counts.update([cls.UNK_TOKEN])
203
+ continue
204
+
205
+ # Color + piece
206
+ token_counts.update([
207
+ m["color"],
208
+ m["piece"],
209
+ m['from'],
210
+ ])
211
+
212
+ if m["capture"]:
213
+ token_counts.update(["CAP"])
214
+
215
+ # --- TO = FIN DE COUP ---
216
+ to_tok = m['to']
217
+
218
+ if m["promotion"]:
219
+ to_tok += f"_PROM_{m['promotion']}"
220
+
221
+ if m["check"] == "+":
222
+ to_tok += "_CHECK"
223
+ elif m["check"] == "#":
224
+ to_tok += "_MATE"
225
+
226
+
227
+
228
+ token_counts.update([to_tok])
229
+
230
+ tokens = [tok for tok, c in token_counts.items() if c >= min_frequency]
231
+ tokens = tokens + ["EOM"]
232
+ tokens = sorted(tokens)
233
+
234
+ special_tokens = [
235
+ cls.PAD_TOKEN,
236
+ cls.BOS_TOKEN,
237
+ cls.EOS_TOKEN,
238
+ cls.UNK_TOKEN,
239
+ ]
240
+
241
+ vocab = {tok: i for i, tok in enumerate(special_tokens + tokens)}
242
+ return cls(vocab=vocab)
243
+
244
+ @classmethod
245
+ def build_vocab_from_dataset(
246
+ cls,
247
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
248
+ split: str = "train",
249
+ column: str = "text",
250
+ min_frequency: int = 500,
251
+ max_samples: Optional[int] = 100000,
252
+ ) -> "ChessTokenizer":
253
+ """
254
+ Build a tokenizer vocabulary from a Hugging Face dataset.
255
+
256
+ Args:
257
+ dataset_name: Name of the dataset on Hugging Face Hub.
258
+ split: Dataset split to use.
259
+ column: Column containing the game strings.
260
+ min_frequency: Minimum frequency for a token to be included (default: 500).
261
+ max_samples: Maximum number of samples to process (default: 100k).
262
+
263
+ Returns:
264
+ A ChessTokenizer with the built vocabulary.
265
+ """
266
+ from datasets import load_dataset
267
+
268
+ dataset = load_dataset(dataset_name, split=split)
269
+
270
+ if max_samples is not None:
271
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
272
+
273
+ def game_iterator():
274
+ for example in dataset:
275
+ yield example[column]
276
+
277
+ return cls.build_vocab_from_iterator_bis(game_iterator(), min_frequency=min_frequency)
278
+
279
+ @property
280
+ def vocab_size(self) -> int:
281
+ """Return the size of the vocabulary."""
282
+ return max(self._vocab.values()) + 1
283
+
284
+ def get_vocab(self) -> Dict[str, int]:
285
+ """Return the vocabulary as a dictionary."""
286
+ return dict(self._vocab)
287
+
288
+
289
+ def _tokenize(self, text: str) -> List[str]:
290
+ """
291
+ Convert a game string into subword tokens.
292
+ Example:
293
+ "WPe2e4 BNg8f6" ->
294
+ ["W","P","FROM_e2","TO_e4_EOM","B","N","FROM_g8","TO_f6_EOM"]
295
+ """
296
+ tokens: List[str] = []
297
+
298
+ MOVE_REGEX = re.compile(
299
+ r"""
300
+ (?P<color>[WB])
301
+ (?P<piece>[PNBRQK])
302
+ (?P<from>[a-h][1-8])
303
+ (?P<capture>x)?
304
+ (?P<to>[a-h][1-8])
305
+ (?P<promotion>[QRBN])?
306
+ (?P<check>[+#])?
307
+ """,
308
+ re.VERBOSE,
309
+ )
310
+
311
+ moves = text.split()
312
+
313
+ for move in moves:
314
+ # --- Castling ---
315
+ if move in ("WKe1g1", "BKe8g8"):
316
+ tokens.extend(["W", "K", "CASTLE_K", "EOM"])
317
+ continue
318
+
319
+ if move in ("WKe1c1", "BKe8c8"):
320
+ tokens.extend(["W", "K", "CASTLE_Q", "EOM"])
321
+ continue
322
+
323
+ m = MOVE_REGEX.fullmatch(move)
324
+ if not m:
325
+ tokens.append(self.UNK_TOKEN)
326
+ continue
327
+
328
+ # Color & piece
329
+ tokens.append(m["color"])
330
+ tokens.append(m["piece"])
331
+ tokens.append(f"{m['from']}")
332
+
333
+ if m["capture"]:
334
+ tokens.append("CAP")
335
+
336
+ # --- TO + FLAGS + EOM ---
337
+ to_tok = f"{m['to']}"
338
+
339
+ if m["promotion"]:
340
+ to_tok += f"_PROM_{m['promotion']}"
341
+
342
+ if m["check"] == "+":
343
+ to_tok += "_CHECK"
344
+ elif m["check"] == "#":
345
+ to_tok += "_MATE"
346
+
347
+
348
+
349
+ tokens.append(to_tok)
350
+ if to_tok:
351
+ tokens.append("EOM")
352
+
353
+ return tokens
354
+
355
+
356
+ def _convert_token_to_id(self, token: str) -> int:
357
+ """Convert a token to its ID."""
358
+ return self._vocab.get(token, self._vocab.get(self.UNK_TOKEN, 0))
359
+
360
+ def _convert_id_to_token(self, index: int) -> str:
361
+ """Convert an ID to its token."""
362
+ return self._ids_to_tokens.get(index, self.UNK_TOKEN)
363
+
364
+ def convert_tokens_to_string(self, tokens: List[str]) -> str:
365
+ special = {
366
+ self.PAD_TOKEN,
367
+ self.BOS_TOKEN,
368
+ self.EOS_TOKEN,
369
+ self.UNK_TOKEN,
370
+ }
371
+
372
+ moves = []
373
+ current = []
374
+
375
+ for tok in tokens:
376
+ if tok in special:
377
+ continue
378
+
379
+ if tok == "EOM":
380
+ moves.append("".join(current) + " ")
381
+ current = []
382
+ continue
383
+
384
+ if tok == "W" or tok == "B":
385
+ current.append(tok)
386
+
387
+ elif tok in {"P","N","B","R","Q","K"}:
388
+ current.append(tok)
389
+
390
+ elif tok == "CAP":
391
+ current.append("x")
392
+
393
+ elif tok.startswith("CASTLE"):
394
+ if tok == "CASTLE_K":
395
+ moves.append("O-O ")
396
+ elif tok == "CASTLE_Q":
397
+ moves.append("O-O-O ")
398
+ current = []
399
+
400
+ else :
401
+ current.append(tok[:2])
402
+ body = tok[2:]
403
+
404
+ if not body:
405
+ continue
406
+ # Split flags
407
+ parts = body.split("_")
408
+ square = parts[0]
409
+ current.append(square)
410
+
411
+ for p in parts[1:]:
412
+ if p == "PROM":
413
+ continue
414
+ elif p in {"Q","R","B","N"}:
415
+ current.append(p)
416
+ elif p == "CHECK":
417
+ current.append("+")
418
+ elif p == "MATE":
419
+ current.append("#")
420
+
421
+
422
+
423
+
424
+ moves.append("".join(current))
425
+
426
+ return "".join(moves)
427
+
428
+
429
+
430
+ def save_vocabulary(
431
+ self,
432
+ save_directory: str,
433
+ filename_prefix: Optional[str] = None,
434
+ ) -> tuple:
435
+ """
436
+ Save the vocabulary to a JSON file.
437
+
438
+ Args:
439
+ save_directory: Directory to save the vocabulary.
440
+ filename_prefix: Optional prefix for the filename.
441
+
442
+ Returns:
443
+ Tuple containing the path to the saved vocabulary file.
444
+ """
445
+ if not os.path.isdir(save_directory):
446
+ os.makedirs(save_directory, exist_ok=True)
447
+
448
+ vocab_file = os.path.join(
449
+ save_directory,
450
+ (filename_prefix + "-" if filename_prefix else "") + "vocab.json",
451
+ )
452
+
453
+ with open(vocab_file, "w", encoding="utf-8") as f:
454
+ json.dump(self._vocab, f, ensure_ascii=False, indent=2)
455
+
456
+ return (vocab_file,)
457
+
458
+
459
+ def count_vocab_from_dataset(
460
+ dataset_name: str = "dlouapre/lichess_2025-01_1M",
461
+ split: str = "train",
462
+ column: str = "text",
463
+ max_samples: Optional[int] = 10000,
464
+ ) -> Dict[str, int]:
465
+ """
466
+ Count token frequencies in a dataset (useful for vocabulary analysis).
467
+
468
+ Args:
469
+ dataset_name: Name of the dataset on Hugging Face Hub.
470
+ split: Dataset split to use.
471
+ column: Column containing the game strings.
472
+ max_samples: Maximum number of samples to process.
473
+
474
+ Returns:
475
+ Dictionary mapping tokens to their frequencies.
476
+ """
477
+ from collections import Counter
478
+ from datasets import load_dataset
479
+
480
+ dataset = load_dataset(dataset_name, split=split)
481
+
482
+ if max_samples is not None:
483
+ dataset = dataset.select(range(min(max_samples, len(dataset))))
484
+
485
+ token_counts = Counter()
486
+
487
+ for example in dataset:
488
+ moves = example[column].strip().split()
489
+ token_counts.update(moves)
490
+
491
+ return dict(token_counts)
tokenizer_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[BOS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[EOS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "12": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ }
35
+ },
36
+ "auto_map": {
37
+ "AutoTokenizer": [
38
+ "tokenizer.ChessTokenizer",
39
+ null
40
+ ]
41
+ },
42
+ "bos_token": "[BOS]",
43
+ "clean_up_tokenization_spaces": false,
44
+ "eos_token": "[EOS]",
45
+ "extra_special_tokens": {},
46
+ "model_max_length": 1000000000000000019884624838656,
47
+ "pad_token": "[PAD]",
48
+ "tokenizer_class": "ChessTokenizer",
49
+ "unk_token": "[UNK]"
50
+ }
vocab.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "[PAD]": 0,
3
+ "[BOS]": 1,
4
+ "[EOS]": 2,
5
+ "[UNK]": 12,
6
+ "B": 4,
7
+ "EOM": 5,
8
+ "K": 6,
9
+ "N": 7,
10
+ "P": 8,
11
+ "Q": 9,
12
+ "R": 10,
13
+ "W": 11,
14
+ "a1": 13,
15
+ "a2": 14,
16
+ "a3": 15,
17
+ "a4": 16,
18
+ "a5": 17,
19
+ "a6": 18,
20
+ "a7": 19,
21
+ "a8": 20,
22
+ "b1": 21,
23
+ "b2": 22,
24
+ "b3": 23,
25
+ "b4": 24,
26
+ "b5": 25,
27
+ "b6": 26,
28
+ "b7": 27,
29
+ "b8": 28,
30
+ "c1": 29,
31
+ "c2": 30,
32
+ "c3": 31,
33
+ "c4": 32,
34
+ "c5": 33,
35
+ "c6": 34,
36
+ "c7": 35,
37
+ "c8": 36,
38
+ "d1": 37,
39
+ "d2": 38,
40
+ "d3": 39,
41
+ "d4": 40,
42
+ "d5": 41,
43
+ "d6": 42,
44
+ "d7": 43,
45
+ "d8": 44,
46
+ "e1": 45,
47
+ "e2": 46,
48
+ "e3": 47,
49
+ "e4": 48,
50
+ "e5": 49,
51
+ "e6": 50,
52
+ "e7": 51,
53
+ "e8": 52,
54
+ "f1": 53,
55
+ "f2": 54,
56
+ "f3": 55,
57
+ "f4": 56,
58
+ "f5": 57,
59
+ "f6": 58,
60
+ "f7": 59,
61
+ "f8": 60,
62
+ "g1": 61,
63
+ "g2": 62,
64
+ "g3": 63,
65
+ "g4": 64,
66
+ "g5": 65,
67
+ "g6": 66,
68
+ "g7": 67,
69
+ "g8": 68,
70
+ "h1": 69,
71
+ "h2": 70,
72
+ "h3": 71,
73
+ "h4": 72,
74
+ "h5": 73,
75
+ "h6": 74,
76
+ "h7": 75,
77
+ "h8": 76
78
+ }