Exemple #1
0
    def king_moves(pos: Position, game: Game) -> List[Position]:
        """Return list of <game.turn> king moves.
        king moves = positions_under_threat + castling
        """

        moves = [
            Move(pos, pos_threat)
            for pos_threat in PositionsUnderThreat.positions_under_king_threat(
                pos, game.turn, game.board)
        ]
        return [*PieceMoves.castling_moves(pos, game), *moves]
Exemple #2
0
    def test_positions_under_king_threat(self):
        """Test of positions_under_king_threat() method."""

        assert sorted(
            PositionsUnderThreat.positions_under_king_threat(
                Position(4, 4), Colour.WHITE, self.board)) == [
                    Position(3, 3),
                    Position(3, 5),
                    Position(4, 5),
                    Position(5, 3)
                ]