KeithG33 commited on
Commit
0c1723c
·
1 Parent(s): 07635ff

add train/test files and builder code

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
ChessBot-Dataset.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob, os, chess.pgn
2
+ from datasets import (
3
+ GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split,
4
+ Features, Value, Array2D
5
+ )
6
+ from adversarial_gym.chess_env import ChessEnv
7
+
8
+ class ChessPGNDataset(GeneratorBasedBuilder):
9
+ VERSION = "0.0.1"
10
+
11
+ def _info(self):
12
+ return DatasetInfo(
13
+ description="Chess positions + moves + results, streamed from PGN shards",
14
+ features=Features({
15
+ "state": Array2D((8,8), dtype="int8"),
16
+ "action": Value("int16"),
17
+ "result": Value("int8"),
18
+ })
19
+ )
20
+
21
+ def _split_generators(self, dl_manager):
22
+ # data_dir is the root of your dataset repo
23
+ data_dir = self.config.data_dir
24
+ return [
25
+ SplitGenerator(
26
+ name=Split.TRAIN,
27
+ gen_kwargs={"shards": glob.glob(os.path.join(data_dir,"train","*.pgn"))}
28
+ ),
29
+ SplitGenerator(
30
+ name=Split.TEST,
31
+ gen_kwargs={"shards": glob.glob(os.path.join(data_dir,"test","*.pgn"))}
32
+ ),
33
+ ]
34
+
35
+ def _generate_examples(self, shards):
36
+ uid = 0
37
+ for path in sorted(shards):
38
+ with open(path, "r") as f:
39
+ while (game := chess.pgn.read_game(f)) is not None:
40
+ board = game.board()
41
+ base = {"1-0":1,"0-1":-1}.get(game.headers["Result"], 0)
42
+ for move in game.mainline_moves():
43
+ state = ChessEnv.get_piece_configuration(board)
44
+ state = state if board.turn else -state
45
+ action = ChessEnv.move_to_action(move)
46
+ result = base * (-1 if board.turn == 0 else 1)
47
+ yield uid, {
48
+ "state": state.astype("int8"),
49
+ "action": int(action),
50
+ "result": int(result),
51
+ }
52
+ uid += 1
53
+ board.push(move)
ChessBot-dataset-0.1.0.zip → test/chesspgn_1.pgn RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3ab9e11d0af2b6e6fe2831837dbb96446d882ab544ae96d7e184f130f078b4f9
3
- size 2547657186
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72a94f35aefb161d85764fbb344889ba23a92a85be3ce57d64e1ca6ea66d8960
3
+ size 7667499
test/chesspgn_106.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2434956b2d3059049914fa2efcfb26a718005b7b0ed17a21a0d50400fffcef48
3
+ size 7601402
test/chesspgn_111.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:adb0ff8ba8c64aedf212ee3c85e92b5e5f90dcd34ef9aaa23dc69ae5d457e186
3
+ size 7674553
test/chesspgn_130.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b770e78ff9c6584a792aa57bb1e65ce39bcd80dd1709aaa71a9767b843c2fe97
3
+ size 7643100
test/chesspgn_148.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44a4e6cf84e317b9f212e3378175d380178c1550ea7cb17a876ca8ea115473d8
3
+ size 7637835
test/chesspgn_152.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12d9f85a8c1d2c9a17d5d58a02f3cc45c29f28f54b03b1ac484bdbf29b405d50
3
+ size 7648965
test/chesspgn_179.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3e59b5d0b6d13840de8ba60323535ef9bc36da57fc6c3a0f0c6747214bb40ab
3
+ size 7562186
test/chesspgn_182.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2ddf42caf97132ae222f9cfd56d752e37f463d10a167c38cfb209268bcfa582
3
+ size 7560298
test/chesspgn_184.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b84b4a5cf4f50382702644fbd1784634c0fdba1e7ae800f18348f48610f8ec79
3
+ size 7553854
test/chesspgn_186.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dbb689454640b13fd0bf5ddd4e019034d35475b11bec66f01abd9d983c14c4c
3
+ size 7585943
test/chesspgn_202.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8a97678c733e01dbf0ac9238b834f3aa259f25daff0e80026b14261d4014d59
3
+ size 7663592
test/chesspgn_206.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15747d9594e34cb0e9140e405f632c759040f9cac725cbbf81bf38b38b0ba062
3
+ size 7631273
test/chesspgn_212.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccb6b6d3d9712d877ef9df8e5dab09c9e7ab203b1dfa3f522cacbd5bacb98a7b
3
+ size 7590912
test/chesspgn_213.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25e8677c1869e8f71db8ff15e1c5782c704893e135f5779db16d6373030e8820
3
+ size 7635459
test/chesspgn_218.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6681ee685786c2cdb748930a14dae7931425b16388ee1138e5f7b957e34dc7a
3
+ size 7644866
test/chesspgn_222.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ffab9aeb1a8b811d6da1f0bda89280f81a0444349459f4432c4c8eb94adb108e
3
+ size 7651674
test/chesspgn_231.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f8fa270c0db9e37784f969ebd5118086c46cf5d93dad9047148d0e85e0c6bf4
3
+ size 7631585
test/chesspgn_259.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5c3ebe4814c2653148205fb4e0eb65660968447c0832fa673caa797a15af354
3
+ size 7658261
test/chesspgn_271.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3e9bec68fca95478594af7fc523c5ff9f954c27d02c3dddb466f343a35f96ba
3
+ size 7659173
test/chesspgn_292.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:142eb18919876962e3a658b8c42bc676c5d67b712bbe5b91ecfc0d83f8d81fd0
3
+ size 7618164
test/chesspgn_305.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92e67d95de9f787fa055694cb178cf9336646671f831a13ee54b729d8ccd705a
3
+ size 7629634
test/chesspgn_306.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dcca62a1fe2e6bf01e6815dd6379c427148715505d0b4dab8c960f27ad5834f
3
+ size 7676944
test/chesspgn_308.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5b74baab9ab88c25ea8f87944f1eb805b3791a7400994bb7e1a41fe288e10cc
3
+ size 7623910
test/chesspgn_310.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac8f0f9e887e65238cec281ed5db048f53902b2d125efeb11469efe74581a266
3
+ size 7601769
test/chesspgn_312.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a708e5ae7c9cfde4b8ed366d9a78fa84c00a7423eeb8c8f8455123bec1382fa4
3
+ size 7644850
test/chesspgn_327.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:622bf27536a4d327311d68fd917fb357184d9fe7b29a05585645c0613828f442
3
+ size 7633173
test/chesspgn_346.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3093d87afc43ba7168534bb69ee956b6b9b0e91d6399a44f63859b126550adcf
3
+ size 7677477
test/chesspgn_365.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92d929b33351773a079db9e9e75c4f770d6bfc1779c9f575f33141be31520647
3
+ size 7577624
test/chesspgn_372.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5311b8233fd4cf9864208fc5b186b3345791a4b782605109a03dc0c65d84437e
3
+ size 7643075
test/chesspgn_373.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74f29a4e721023bc109a614142ff3afe37a3c80d038d9c924ea66849d3641fca
3
+ size 7653652
test/chesspgn_379.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50021e70cb090c5ab51cf5a1c462b896f07bc227cb091c559a28c4b3b156c6a1
3
+ size 7605879
test/chesspgn_381.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:028aa0ce87fd7a9d3a7aa16ec5c2e2089cd9a24acad3451862a93acc1df10ca5
3
+ size 7618541
test/chesspgn_387.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76a98a4cfa10f874685c0db2243ca422f767a8b04be1bf46b4eca2ebf01fbd0c
3
+ size 7629891
test/chesspgn_389.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a352ba100320a29c1f93bee5d7a13258d2ac7be0f4d435689d1cdb4930fbb72
3
+ size 7665189
test/chesspgn_390.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe3ede83100dfaf7ab82a0cfac2caf7510e1594e2bfaff97192da0a6eab2b180
3
+ size 7673865
test/chesspgn_403.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3daa8d1fdfeee909343368767ed2c5c623b71fd3541fb16fd8fdbeade5ad18b4
3
+ size 7617478
test/chesspgn_417.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1644c189c4687e672b24d2a7170556d0f7bc7e9eb965c48557d6578473435f8c
3
+ size 7647702
test/chesspgn_419.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61e022539fd093daca65e5ca27a5b4b21d237c34ef75d61aae33ed01ac351710
3
+ size 7663356
test/chesspgn_424.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76b9e00fa19dc85a8c19b51564e33b59570e9e7b9a59aa8958202d9794b6ab82
3
+ size 7685343
test/chesspgn_440.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b70942fe96c5e74e588a39016f13d5896dafb784592d90be61f70ffbe1217059
3
+ size 7659343
test/chesspgn_458.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:965bc322d60b1eafad39cd676d168dbb48decfc7ab998766590bdaeb6ada7cfc
3
+ size 7653806
test/chesspgn_465.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3604723003e95aa0c065b27e1888653e392d1e1c86c465b98d2c95149c07a89a
3
+ size 7648225
test/chesspgn_486.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e00d4803c11daef9df182a2aa622c47d1fde62b21f5cff6ec4b00ee46663149
3
+ size 7593314
test/chesspgn_509.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47a2e30d09f9e72905a96dc4ca0d2be86fec0664aefbbc26621a3a218b5b28cc
3
+ size 7614205
test/chesspgn_522.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b10b80948f8841e1efff4e325632109c48271b7ddb60d70ad949e6d08588135
3
+ size 7595344
test/chesspgn_532.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a18f9db1a036bb98b924059a742c3b66708c1cd453beb70142956b2e75f557dd
3
+ size 7628192
test/chesspgn_536.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ce18d38530b92ffe803bfc871fdf874b2be69fd53132a3ad13edab262871676
3
+ size 7621198
test/chesspgn_560.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbcb767b3ab2f38063fcd0e4db8c9999b13766d8b0cf83b2bc781b4faa21383e
3
+ size 7574228
test/chesspgn_569.pgn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:186e6815bc21239850d853ac25bd051fab706972812937d712c6cd10f22c2087
3
+ size 7641614