示例#1
0
    def apply(self, board: Board):
        if getRelativePointLocation(self.color, self.start) > self.die:
            raise IllegalMoveException("Move cannot be made given the die value " + str(self.die))
        elif getRelativePointLocation(self.color, self.start) < self.die:
            if board.farthestBack(self.color) != self.start:
                raise IllegalMoveException(
                    "You must move the farthest back piece off that you can with die " + str(self.die))

        scratch = board.__deepcopy__()

        # VALID MOVEMENT
        scratch.removeFromLocation(self.color, self.start)
        scratch.moveOff(self.color)

        return scratch
示例#2
0
    def apply(self, board: Board):
        if board.numAt(getOtherColor(self.color), self.end) > 1:
            raise IllegalMoveException("Other player occupies the location " + str(self.end))

        scratch = board.__deepcopy__()

        # VALID MOVEMENT, check if hit
        if scratch.numAt(getOtherColor(self.color), self.end) == 1:
            scratch.removeFromLocation(getOtherColor(self.color), self.end)
            scratch.moveToBar(getOtherColor(self.color))
            self.hit = True

        scratch.moveFromBar(self.color)
        scratch.moveToLocation(self.color, self.end)

        return scratch