def test_getstatus1(self): """Testing bare black king is not draw in Atomic variant""" board = AtomicBoard(setup=FEN2) board = board.move(parseSAN(board, 'Qxc2')) print(board) self.assertEqual(getStatus(board), (BLACKWON, WON_KINGEXPLODE))
def test_validate2(self): """Testing explode king vs mate in Atomic variant""" board = AtomicBoard(setup=FEN1) board = board.move(parseSAN(board, 'Nc7+')) print(board) # King explosion takes precedence over mate! self.assertTrue(validate(board, parseSAN(board, 'Qxd2'))) self.assertTrue(validate(board, parseSAN(board, 'Qxf2'))) self.assertTrue(not validate(board, parseSAN(board, 'Qxb2'))) self.assertTrue(not validate(board, parseSAN(board, 'Qe4+')))
def test_validate1(self): """Testing castling rights lose in explosion in Atomic variant""" board = AtomicBoard(setup=FEN1) board = board.move(parseSAN(board, 'Nxa7')) print(board) # Rook exploded, no O-O-O anymore! self.assertTrue(validate(board, parseSAN(board, 'b6'))) self.assertTrue(not validate(board, parseSAN(board, 'a6'))) self.assertTrue(not validate(board, parseSAN(board, 'Rb8'))) self.assertTrue(not validate(board, parseSAN(board, 'O-O-O')))
def test_getstatus2(self): """Testing bare white king is not draw in Atomic variant""" board = AtomicBoard(setup=FEN3) self.assertTrue(not validate(board, parseSAN(board, 'Kxg7'))) self.assertTrue(not validate(board, parseSAN(board, 'Kg8'))) self.assertTrue(not validate(board, parseSAN(board, 'Kh7'))) print(board) self.assertEqual(getStatus(board), (DRAW, DRAW_STALEMATE))
def walk(node, path): if node.prev is None: # initial game board if variant == "Fischerandom": board = FRCBoard(setup=node.asFen(), lboard=node) elif variant == "Atomic": board = AtomicBoard(setup=node.asFen(), lboard=node) elif variant == "Crazyhouse": board = CrazyhouseBoard(setup=node.asFen(), lboard=node) elif variant == "Wildcastle": board = WildcastleBoard(setup=node.asFen(), lboard=node) elif variant == "Suicide": board = SuicideBoard(setup=node.asFen(), lboard=node) elif variant == "Losers": board = LosersBoard(setup=node.asFen(), lboard=node) elif variant == "Kingofthehill": board = KingOfTheHillBoard(setup=node.asFen(), lboard=node) else: board = Board(setup=node.asFen(), lboard=node) else: move = Move(node.lastMove) try: board = node.prev.pieceBoard.move(move, lboard=node) except: raise LoadingError( _("Invalid move."), "%s%s" % (move_count(node, black_periods=True), move)) if node.next is None: model.variations.append(path + [board]) else: walk(node.next, path + [board]) for child in node.children: if isinstance(child, list): if len(child) > 1: # non empty variation, go walk walk(child[1], list(path)) else: if not self.has_emt: self.has_emt = child.find("%emt") >= 0 if not self.has_eval: self.has_eval = child.find("%eval") >= 0
def test_getstatus3(self): """Testing possible to mate with the queen unaided in Atomic variant""" board = AtomicBoard(setup=FEN4) print(board) self.assertEqual(getStatus(board), (WHITEWON, WON_MATE))
def test_getstatus4(self): """Testing possible move into check when king touch saves the king""" board = AtomicBoard(setup=FEN5) print(board) self.assertTrue(validate(board, parseSAN(board, 'Kg5')))