Esempio n. 1
0
    def test_validate(self):
        """Testing validate move in Sittuyin variant"""

        board = SittuyinBoard(setup=FEN0)
        print(board)
        # no promotion if we have Met (queen)
        self.assertTrue(validate(board, parseAN(board, 'f4f3')))
        self.assertTrue(validate(board, parseAN(board, 'b2b1')))
        self.assertTrue(validate(board, parseAN(board, 'b2c1')))

        self.assertFalse(validate(board, parseAN(board, 'b2b2f')))
        self.assertFalse(validate(board, parseAN(board, 'b2a1f')))
        self.assertFalse(validate(board, parseAN(board, 'f4f3f')))
        self.assertFalse(validate(board, parseAN(board, 'b2b1f')))
        self.assertFalse(validate(board, parseAN(board, 'b2c1f')))

        board = SittuyinBoard(setup=FEN1)
        print(board)
        # but (optional) promotion if we don't have Met (queen)
        self.assertTrue(validate(board, parseAN(board, 'b2b2f')))
        self.assertTrue(validate(board, parseSAN(board, 'b2=f')))
        self.assertEqual(parseAN(board, 'b2b2f'), parseSAN(board, 'b2=f'))
        self.assertTrue(validate(board, parseAN(board, 'b2a1f')))
        self.assertTrue(validate(board, parseSAN(board, 'a1=f')))
        self.assertEqual(parseAN(board, 'b2a1f'), parseSAN(board, 'a1=f'))
        self.assertTrue(validate(board, parseAN(board, 'b2c1')))
        self.assertTrue(validate(board, parseAN(board, 'f4f3')))

        self.assertFalse(validate(board, parseAN(board, 'f4f3f')))
        self.assertFalse(validate(board, parseAN(board, 'b2b2')))
        self.assertFalse(validate(board, parseAN(board, 'b2b1f')))
        self.assertFalse(validate(board, parseAN(board, 'b2c1f')))
Esempio n. 2
0
    def test_validate(self):
        """Testing validate move in Sittuyin variant"""

        board = SittuyinBoard(setup=FEN0)
        print(board)
        self.assertTrue(validate(board, parseAN(board, 'f4f3')))
        self.assertTrue(validate(board, parseAN(board, 'b2b1')))
        self.assertTrue(validate(board, parseAN(board, 'b2c1')))

        # no promotion if we have Met (queen)
        self.assertFalse(validate(board, parseAN(board, 'b2b2f')))
        self.assertFalse(validate(board, parseAN(board, 'b2a1f')))
        self.assertFalse(validate(board, parseAN(board, 'f4f3f')))
        self.assertFalse(validate(board, parseAN(board, 'b2b1f')))
        self.assertFalse(validate(board, parseAN(board, 'b2c1f')))

        board = SittuyinBoard(setup=FEN1)
        print(board)
        # but (optional) promotion if we don't have Met (queen)
        self.assertFalse(validate(board, parseAN(board, 'b2b2f')))
        self.assertFalse(validate(board, parseSAN(board, 'b2=f')))
        self.assertEqual(parseAN(board, 'b2b2f'), parseSAN(board, 'b2=f'))
        self.assertTrue(validate(board, parseAN(board, 'b2a1f')))
        self.assertTrue(validate(board, parseSAN(board, 'a1=f')))
        self.assertEqual(parseAN(board, 'b2a1f'), parseSAN(board, 'a1=f'))
        self.assertTrue(validate(board, parseAN(board, 'b2c1')))
        self.assertTrue(validate(board, parseAN(board, 'f4f3')))

        self.assertFalse(validate(board, parseAN(board, 'f4f3f')))
        self.assertFalse(validate(board, parseAN(board, 'b2b2')))
        self.assertFalse(validate(board, parseAN(board, 'b2b1f')))
        self.assertFalse(validate(board, parseAN(board, 'b2c1f')))

        board = SittuyinBoard(setup=FEN2)
        print(board)
        # simple pawn move can give check
        self.assertTrue(validate(board, parseAN(board, 'd6d7')))
        # pawn can promote in place
        self.assertTrue(validate(board, parseAN(board, 'd6d6f')))
        # pawn promotion move can't give check
        self.assertFalse(validate(board, parseAN(board, 'd6c7f')))
        self.assertFalse(validate(board, parseAN(board, 'd6e7f')))

        board = SittuyinBoard(setup=FEN3)
        print(board)
        self.assertTrue(validate(board, parseAN(board, 'd6d7')))
        # last pawn being enywhere can promote
        self.assertTrue(validate(board, parseAN(board, 'd6d6f')))
        self.assertTrue(validate(board, parseAN(board, 'd6c7f')))
        self.assertTrue(validate(board, parseAN(board, 'd6c5f')))
        self.assertTrue(validate(board, parseAN(board, 'd6e5f')))
        # pawn promotion move can't give check
        self.assertFalse(validate(board, parseAN(board, 'd6e7f')))
Esempio n. 3
0
    def test_san_promotion_ambiguity(self):
        """Testing Sittuyin promotion SAN parser"""

        board = SittuyinBoard(setup=FEN6)
        print(board)
        self.assertNotEqual(parseAN(board, 'd4c3f'), parseSAN(board, 'c3=f'))
        self.assertEqual(parseAN(board, 'b4c3f'), parseSAN(board, 'c3=f'))

        board = SittuyinBoard(setup=FEN7)
        print(board)
        self.assertNotEqual(parseAN(board, 'f5e6f'), parseSAN(board, 'e6=f'))
        self.assertEqual(parseAN(board, 'd5e6f'), parseSAN(board, 'e6=f'))
Esempio n. 4
0
    def test_genCheckEvasions(self):
        """Testing validate move in Sittuyin variant"""
        board = SittuyinBoard(setup=FEN4)
        print(board)

        moves = set()
        for move in genCheckEvasions(board.board):
            moves.add(toAN(board.board, move))
        self.assertEqual(moves, set(("d5c6", "d5d6", "d5e6=F")))
Esempio n. 5
0
    def test_genAllMoves(self):
        """Testing validate move in Sittuyin variant"""
        board = SittuyinBoard(setup=FEN4)
        print(board)

        moves = set()
        for move in genAllMoves(board.board):
            moves.add(toAN(board.board, move))
        # pseudo legal moves
        m = set(("f6e7", "f6f7", "f6g7", "f6e6", "f6g6", "f6e5", "f6f5", "f6g5", "d5c6", "d5d6", "d5e6=F", "d5c4=F"))
        self.assertEqual(moves, m)