This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import chess | |
| import chess.engine | |
| engine_path = "stockfish" | |
| engine = chess.engine.SimpleEngine.popen_uci(engine_path) | |
| def evaluate_chess960_positions(): | |
| positions = [] | |
| for i in range(960): | |
| board = chess.Board.from_chess960_pos(i) | |
| info = engine.analyse(board, chess.engine.Limit(depth=15)) | |
| eval_score = info["score"].relative.score(mate_score=10000) | |
| positions.append((i, eval_score)) | |
| return sorted(positions, key=lambda x: x[1], reverse=True)[:10] | |
| top_positions = evaluate_chess960_positions() | |
| engine.quit() | |
| for pos_id, score in top_positions: | |
| print(f"Position #{pos_id}: White advantage {score} centipawns") | |
| """ | |
| Position #111: White advantage 88 centipawns | |
| Position #314: White advantage 88 centipawns | |
| Position #408: White advantage 80 centipawns | |
| Position #880: White advantage 78 centipawns | |
| Position #794: White advantage 77 centipawns | |
| Position #760: White advantage 72 centipawns | |
| Position #848: White advantage 68 centipawns | |
| Position #317: White advantage 65 centipawns | |
| Position #783: White advantage 65 centipawns | |
| Position #882: White advantage 65 centipawns | |
| """ |