Exemple #1
0
 def test_validate_fen(self):
     # valid
     for variant, positions in variant_positions.items():
         for fen in positions:
             self.assertEqual(sf.validate_fen(fen, variant), sf.FEN_OK, "{}: {}".format(variant, fen))
     # invalid
     for variant, positions in invalid_variant_positions.items():
         for fen in positions:
             self.assertNotEqual(sf.validate_fen(fen, variant), sf.FEN_OK, "{}: {}".format(variant, fen))
     # chess960
     self.assertEqual(sf.validate_fen(CHESS960, "chess", True), sf.FEN_OK, "{}: {}".format(variant, fen))
     self.assertEqual(sf.validate_fen("nrbqbkrn/pppppppp/8/8/8/8/PPPPPPPP/NRBQBKRN w BGbg - 0 1", "newzealand", True), sf.FEN_OK, "{}: {}".format(variant, fen))
     # all variants starting positions
     for variant in sf.variants():
         fen = sf.start_fen(variant)
         self.assertEqual(sf.validate_fen(fen, variant), sf.FEN_OK, "{}: {}".format(variant, fen))
Exemple #2
0
 def test_variants_loaded(self):
     variants = sf.variants()
     self.assertTrue("shogun" in variants)
Exemple #3
0
        print(board.legal_moves())

    board = FairyBoard("shouse")
    for move in ("e2e4", "E@d4", "g1f3", "e7e6", "b1c3", "H@b6", "d2d3",
                 "f8b4", "c1e3", "d4b5", "e3b6", "a7b6", "d1d2e", "B@c6",
                 "f1e2", "b5h5"):
        print("push move", move, board.get_san(move))
        if board.move_stack:
            print("is_checked(), insuff material, draw?", board.is_checked(),
                  board.insufficient_material(), board.is_claimable_draw())
        board.push(move)
        board.print_pos()
        print(board.fen)
        print(board.legal_moves())

    board = FairyBoard("empire")
    print(board.fen)
    board.print_pos()
    print(board.legal_moves())
    print([board.get_san(move) for move in board.legal_moves()])

    board = FairyBoard("ordamirror")
    print(board.fen)
    board.print_pos()
    print(board.legal_moves())
    print([board.get_san(move) for move in board.legal_moves()])

    print(sf.version())
    print(sf.info())
    print(sf.variants())