diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-08 15:22:29 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-08 15:22:29 +0200 |
| commit | 9cbe5a0fbd3ca3a10703452d2aaf3a5c3759c704 (patch) | |
| tree | 9855029cd269051c5effcca36223f38825cc3111 /match-manager/extract.py | |
| parent | f86ea4529b5bdc6457e6d1fc86a43133132d4252 (diff) | |
removing experiment
Diffstat (limited to 'match-manager/extract.py')
| -rw-r--r-- | match-manager/extract.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/match-manager/extract.py b/match-manager/extract.py deleted file mode 100644 index 61125a0..0000000 --- a/match-manager/extract.py +++ /dev/null @@ -1,55 +0,0 @@ -import random - -import chess.pgn - -INPUT = "big_games.pgn" -OUTPUT = "positions.txt" - - -def get_random_position(game): - moves = list(game.mainline_moves()) - - # Game is too short - if len(moves) <= 10: - return None - - move_number = random.randint(10, min(len(moves) - 1, 40)) - - board = game.board() - - for i, move in enumerate(moves): - board.push(move) - if i == move_number: - break - - return board.fen() - - -def main(): - max_games = int(input("Enter number of game to extract: ")) - - saved = 0 - - with open(INPUT, "r") as pgn_file, open(OUTPUT, "w") as fen_file: - for i in range(max_games): - game = chess.pgn.read_game(pgn_file) - - if game is None: - break - - fen = get_random_position(game) - - if fen is None: - continue - - fen_file.write(fen + "\n") - - saved += 1 - - print(f"{i + 1}/{max_games} > saved {saved}") - - print(f"Saved {saved} positions.") - - -if __name__ == "__main__": - main() |
