def test_parse_mecking_h_donner_1971(): parser = Parser.from_pgn(get_input.get('mecking_h_donner_1971.pgn')) stats = get_parser_stats(parser) total = stats['total'] white_pieces = stats['white_pieces'] white_destinations = stats['white_destinations'] col_helpers = stats['col_helpers'] row_helpers = stats['row_helpers'] black_pieces = stats['black_pieces'] black_destinations = stats['black_destinations'] upgrades = stats['upgrades'] en_passants = stats['en_passants'] queensides = stats['queensides'] kingsides = stats['kingsides'] assert len(parser.moves) == total assert (2 * total) - kingsides - queensides - 1 == sum( white_destinations.values()) + sum(black_destinations.values()) assert 0 == en_passants assert 2 == kingsides assert 0 == queensides assert {} == upgrades assert dict(F=1) == col_helpers assert {} == row_helpers assert dict(Pawn=8, Rook=1, Knight=3, Bishop=2, Queen=2, King=1) == white_pieces assert 2 == white_destinations[Point(4, 2)] assert 15 == len(white_destinations) assert dict(Pawn=6, Knight=3, Bishop=5, Queen=1, King=1) == black_pieces assert 3 == black_destinations[Point(4, 2)] assert 11 == len(black_destinations)
def test_game_from_parser_b(): game = Game() parser = Parser.from_pgn(get_input.get('raphael_hiaves_2006.pgn')) game_status, competitive_ending = game.start_game(parser) assert game_status == Status.Checkmate assert competitive_ending.value is None
def test_parse_length8848_5(): parser = Parser.from_pgn(get_input.get('length8848.5.pgn')) stats = get_parser_stats(parser) total = stats['total'] white_pieces = stats['white_pieces'] white_destinations = stats['white_destinations'] col_helpers = stats['col_helpers'] row_helpers = stats['row_helpers'] black_pieces = stats['black_pieces'] black_destinations = stats['black_destinations'] upgrades = stats['upgrades'] en_passants = stats['en_passants'] queensides = stats['queensides'] kingsides = stats['kingsides'] white_sum = sum(white_destinations.values()) black_sum = sum(black_destinations.values()) assert 8849 == total assert 1 == white_sum - black_sum assert (2 * total) - kingsides - queensides - 1 == white_sum + black_sum assert 0 == en_passants assert 0 == kingsides assert 0 == queensides assert dict(Queen=16) == upgrades assert dict(A=593, B=762, C=885, D=914, E=750, F=803, G=781, H=536) == col_helpers assert { 1: 173, 2: 158, 3: 198, 4: 183, 5: 142, 6: 126, 7: 95, 8: 81 } == row_helpers assert dict(Pawn=48, Rook=962, Knight=1487, Bishop=716, Queen=4818, King=818) == white_pieces assert 144 == white_destinations[Point(3, 2)] assert 64 == len(white_destinations) assert dict(Pawn=48, Rook=1269, Knight=531, Bishop=701, Queen=5146, King=1153) == black_pieces assert 121 == black_destinations[Point(3, 2)] assert 64 == len(black_destinations)
def main(): game = Game() parser = Parser.from_pgn(get_input.get('length8848.5.pgn')) try: game.start_game(parser) except EOFError: print('Game forcefully quit!') finally: del game
def test_parse_fischer_spassky_1992(): parser = Parser.from_pgn(get_input.get('fischer_spassky_1992.pgn')) stats = get_parser_stats(parser) total = stats['total'] white_pieces = stats['white_pieces'] white_destinations = stats['white_destinations'] col_helpers = stats['col_helpers'] row_helpers = stats['row_helpers'] black_pieces = stats['black_pieces'] black_destinations = stats['black_destinations'] upgrades = stats['upgrades'] en_passants = stats['en_passants'] queensides = stats['queensides'] kingsides = stats['kingsides'] assert len(parser.moves) == total assert (2 * total) - kingsides - queensides - 1 == sum( white_destinations.values()) + sum(black_destinations.values()) assert 0 == en_passants assert 2 == kingsides assert 0 == queensides assert {} == upgrades assert dict(A=1, B=2) == col_helpers assert {} == row_helpers assert dict(Pawn=14, Rook=7, Knight=7, Bishop=8, Queen=3, King=4) == white_pieces assert 3 == white_destinations[Point(0, 4)] assert 28 == len(white_destinations) assert dict(Pawn=12, Rook=3, Knight=12, Bishop=5, Queen=3, King=7) == black_pieces assert 3 == black_destinations[Point(4, 1)] assert 29 == len(black_destinations)
def test_parse_raphael_hiaves_2006(): parser = Parser.from_pgn(get_input.get('raphael_hiaves_2006.pgn')) stats = get_parser_stats(parser) total = stats['total'] white_pieces = stats['white_pieces'] white_destinations = stats['white_destinations'] col_helpers = stats['col_helpers'] row_helpers = stats['row_helpers'] black_pieces = stats['black_pieces'] black_destinations = stats['black_destinations'] upgrades = stats['upgrades'] en_passants = stats['en_passants'] queensides = stats['queensides'] kingsides = stats['kingsides'] assert len(parser.moves) == total assert (2 * total) - kingsides - queensides == sum( white_destinations.values()) + sum(black_destinations.values()) assert 1 == en_passants assert 2 == kingsides assert 0 == queensides assert dict(Queen=1) == upgrades assert dict(A=2, C=1, F=2) == col_helpers assert {} == row_helpers assert dict(Pawn=6, Rook=3, Knight=5, Bishop=2, Queen=2, King=2) == white_pieces assert 3 == white_destinations[Point(4, 3)] assert 15 == len(white_destinations) assert dict(Pawn=10, Rook=2, Knight=3, Bishop=3, Queen=1, King=1) == black_pieces assert 4 == black_destinations[Point(4, 3)] assert 14 == len(black_destinations)
def test_parse_lucky_bardwick_1995(): parser = Parser.from_pgn(get_input.get('lucky_bardwick_1995.pgn')) stats = get_parser_stats(parser) total = stats['total'] white_pieces = stats['white_pieces'] white_destinations = stats['white_destinations'] col_helpers = stats['col_helpers'] row_helpers = stats['row_helpers'] black_pieces = stats['black_pieces'] black_destinations = stats['black_destinations'] upgrades = stats['upgrades'] en_passants = stats['en_passants'] queensides = stats['queensides'] kingsides = stats['kingsides'] assert len(parser.moves) == total assert (2 * total) - kingsides - queensides == sum( white_destinations.values()) + sum(black_destinations.values()) assert 0 == en_passants assert 0 == kingsides assert 1 == queensides assert {} == upgrades assert dict(D=1, F=1) == col_helpers assert {} == row_helpers assert dict(Pawn=20, Rook=55, Knight=30, Bishop=3, Queen=8, King=27) == white_pieces assert 10 == white_destinations[Point(4, 4)] assert 49 == len(white_destinations) assert dict(Pawn=12, Rook=60, Knight=15, Bishop=8, Queen=3, King=45) == black_pieces assert 8 == black_destinations[Point(6, 3)] assert 51 == len(black_destinations)