コード例 #1
0
    def _check_illegal_move(self,
                            to: Point,
                            *,
                            ignore_color: bool = False) -> bool:
        # Cannot move outisde board or to same spot
        if not to.is_valid() or self._pos == to:
            return True

        if ignore_color:
            return False

        # Cannot move to teammate spot
        actual_piece = self._board[to]
        if actual_piece is not None and actual_piece.color == self.color:
            return True

        return False
コード例 #2
0
ファイル: test_point.py プロジェクト: chaburkland/chess_ai
def test_constructor():
    point = Point()
    assert not point.is_valid()

    point = Point(1, 4)
    assert point.x == 1 and point.y == 4