コード例 #1
0
    def getGameEnded(self,currentInput_box, threshold):
        """
        Input:
            board: current board
            player: current player (1 or -1)

        Returns:
            r: 0 if game has not ended. 1 if player won, -1 if player lost,
               small non-zero value for draw.

        """


        # TODO: situation for empty box
        if currentInput_box.is_empty():
            return -5


        if 1 not in self.getValidMoves(currentInput_box, threshold):
            currentValue = [[currentInput_box[i].diam()/2 + currentInput_box[i][0],currentInput_box[i].diam()/2 + currentInput_box[i][0]] for i in range(len(currentInput_box))]
            #print(pi.IntervalVector(currentValue)[0])
            #print(self.function.eval(pi.IntervalVector(currentValue))[0])
            return 1 - np.abs(self.function.eval(pi.IntervalVector(currentValue))[0])
        else:
            return 0
コード例 #2
0
    def distortInputbox(self, currentInputbox):
        newBox = []
        for i in range(len(currentInputbox)):
            cur = []
            delta = currentInputbox[i].diam()
            cur.append(currentInputbox[i][0] +
                       (-1)**(np.random.randint(0, 2)) * delta *
                       np.random.sample() / 10)
            cur.append(currentInputbox[i][1] +
                       (-1)**(np.random.randint(0, 2)) * delta *
                       np.random.sample() / 10)
            newBox.append(cur)

        return pi.IntervalVector(newBox)
コード例 #3
0

if __name__ == '__main__':

    X = np.array([[0, 0, 0, 0.5]]).T  # [x, y, theta, v].T
    a = np.array([[-5, -5]]).T  # landmark

    t0 = 0
    tmax = 20
    dt = 0.1  # step of the simulation
    T = np.arange(t0, tmax, dt)

    tm = 3  # period between two SIVIAs
    i = 0  # number of SIVIAs already computed

    P = pyibex.IntervalVector(2, [-15, 15])  # SIVIA init box
    vibes.beginDrawing()
    for t in T:
        print(t)

        u = np.array([[0, 0]]).T  # command
        X += dt * f(X, u)  # Euler's scheme
        if t > tm * (i + 1):  # SIVIA
            d = getDistanceFromLandmark(X)
            fCorr = pyibex.Function(
                "x", "y", "({0}-x)^2 + ({1}-y)^2".format(a[0, 0], a[1, 0]))
            if i == 0:  # first SIVIA
                ctc = pyibex.CtcFwdBwd(fCorr, sqr(d))
            else:
                fPred = pyibex.Function(
                    'x', 'y',
コード例 #4
0
    X = np.array([[0, 0, 0, 50]], dtype=np.float64).T  # [x, y, theta, v].T

    dh = 0.5
    dv = 1
    dtheta = 0.01

    t0 = 0
    tmax = 60
    dt = 0.1  # step of the simulation
    T = np.arange(t0, tmax, dt)

    tm = 0.3  # period between two SIVIAs
    i = 0  # number of SIVIAs already computed

    P = pyibex.IntervalVector(2, [-1000, 1000])  # SIVIA init box
    vibes.beginDrawing()

    for t in T:

        print(t)
        """measurement step"""
        # velocity
        v_noise = dv * (2 * np.random.rand() - 1)
        v_measured = X[3, 0] + v_noise
        v = pyibex.Interval(v_measured - dv, v_measured + dv)

        # heading
        theta_noise = dtheta * (2 * np.random.rand() - 1)
        theta_measured = X[2, 0] + theta_noise
        theta = pyibex.Interval(theta_measured - dtheta,
コード例 #5
0

if __name__ == '__main__':
    
    X = np.array([[0, 0, 0, 0.5]]).T  # [x, y, theta, v].T
    a = np.array([[-5, -5]]).T  # landmark

    t0 = 0
    tmax = 60
    dt = 0.1  # step of the simulation
    T = np.arange(t0, tmax, dt)
    
    tm = 0.3  # period between two SIVIAs
    i = 0  # number of SIVIAs already computed
    
    P = pyibex.IntervalVector(2, [-20,20])  # SIVIA init box
    vibes.beginDrawing()

    vibes.newFigure("correction")
    time.sleep(2)

    for t in T:
        print(t)
        
        u = np.array([[0,0.3]]).T  # command
        X += dt*f(X, u)  # Euler's scheme
        if t > tm*(i+1):  # SIVIA
            d = getDistanceFromLandmark(X)
            fCorr = pyibex.Function("x","y","({0}-x)^2 + ({1}-y)^2".format(a[0,0], a[1,0]))
            if i == 0:  # first SIVIA
                ctc = pyibex.CtcFwdBwd(fCorr, sqr(d))