コード例 #1
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def collision_aw_asl(xy, vxy, w, asxy):
    th_col = dc.calc_th(xy, asxy)
    v, th = dc.calc_v(vxy), dc.calc_th(vxy)
    # relative velocity(+)
    vt = v * math.sin(th - th_col) # tangent velocity
    vn = max(0.0, v * math.cos(th - th_col)) # normal velocity
    
    v_threshold = 1
    ni_m = vn
    if vn <= v_threshold:
        ni_m *= 0.5
    maxFriction = FRICTION_STONES * ni_m
    oldTangentLambda = vt / 6.0
    ti_m = max(-maxFriction, min(oldTangentLambda, maxFriction))
    dw = ti_m * 2.0 / dc.STONE_RADIUS
    
    # update
    asv = np.hypot(ni_m, ti_m)
    asth = np.arctan2(ni_m, ti_m) + th_col
    asw = dw
    asvxy = (asv * math.sin(asth), asv * math.cos(asth))
                
    awv = np.hypot(vn - ni_m, vt - ti_m)
    awth = np.arctan2(vn - ni_m, vt - ti_m) + th_col
    aww = w + dw
    awvxy = (awv * math.sin(awth), awv * math.cos(awth))
                
    return awvxy, aww, asvxy, asw
コード例 #2
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def collision_aw_aw(xy0, vxy0, w0, xy1, vxy1, w1):
    th_col = dc.calc_th(xy0, xy1)
    
    v0, th0 = dc.calc_v(vxy0), dc.calc_th(vxy0)
    v0n = v0 * math.cos(th0 - th_col)
    v0t = v0 * math.sin(th0 - th_col)
    
    v1, th1 = dc.calc_v(vxy1), dc.calc_th(vxy1)
    v1n = v1 * math.cos(th1 - th_col)
    v1t = v1 * math.sin(th1 - th_col)
            
    vn, vt = v0n - v1n, v0t - v1t
        
    v_threshold = 1
    ni_m = vn
    if abs(vn) <= v_threshold:
        ni_m *= 0.5
    maxFriction = FRICTION_STONES * ni_m
    oldTangentLambda = vt / 6.0
    ti_m = max(-maxFriction, min(oldTangentLambda, maxFriction))
    dw = ti_m * 2.0 / dc.STONE_RADIUS
            
    # update
    awv1 = np.hypot(v1n + ni_m, v1t + ti_m)
    awth1 = np.arctan2(v1n + ni_m, v1t + ti_m) + th_col
    aww1 = w1 + dw
    awvxy1 = (awv1 * math.sin(awth1), awv1 * math.cos(awth1))
            
    awv0 = np.hypot(v0n - ni_m, v0t - ti_m)
    awth0 = np.arctan2(v0n - ni_m, v0t - ti_m) + th_col
    aww0 = w0 + dw
    awvxy0 = (awv0 * math.sin(awth0), awv0 * math.cos(awth0))

    return awvxy0, aww0, awvxy1, aww1
コード例 #3
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def calc_vxy_by_xyw(oxy, xy, w):
    v = calc_v_by_r(dc.calc_r(oxy, xy))
    #print("theta =", dc.calc_th(oxy, xy))
    theta = dc.calc_th(oxy, xy)
    #print(theta)
    vtheta = calc_vtheta_by_theta(theta, w)
    vx = v * math.sin(vtheta)
    return (vx, v * math.cos(vtheta))
コード例 #4
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def calc_vxy_by_xylrw(oxy, xy, _R, w):
    l = dc.calc_r(oxy, xy)
    R = l + _R # not acculate
    v = calc_v_by_r(R)
    r = calc_r_by_lv(l, v)
    
    cos_alpha = ((l ** 2) + (R ** 2) - (r ** 2)) / (2 * l * R)
    alpha = math.acos(cos_alpha)
    if w < 0:
        alpha = -alpha
    vtheta = calc_vtheta_by_theta(dc.calc_th(oxy, xy) + alpha, w)
    return np.matmul(rotationMatrix(-vtheta), (0, v))
コード例 #5
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def step_xy_vxy_by_xy_vxywt(xy, vxy, w, t):
    V = dc.calc_v(vxy)
    R = calc_r_by_v(V)
    Theta = calc_theta_by_r(R)
    v = V - FRICTION_RINK * t
    r = calc_r_by_v(v)
    #print(V, v, r)
    theta = calc_theta_by_r(r)
    print(r, Theta - theta)
    l2 = (R ** 2) + (r ** 2) - 2 * R * r * math.cos(Theta - theta)
    l = math.sqrt(l2)
    #print("l =", l)
    #cos_beta = ((l ** 2) + (R ** 2) - (r ** 2)) / (2 * l * R)
    #beta = math.acos(cos_beta)
    sin_beta = r / l * math.sin(Theta - theta)
    beta = math.asin(sin_beta)
    #print("beta =", beta)
    
    dtheta = Theta - theta
    alpha = ALPHA

    if w < 0:
        dtheta = -dtheta
        alpha = -alpha
        beta = -beta
    
    #print("ovtheta =", dc.calc_th(vxy), "dtheta =", dtheta)

    ntheta = dc.calc_th(vxy) + alpha - beta
    nvtheta = dc.calc_th(vxy) + dtheta

    #print("ntheta =", ntheta, "nvtheta =", nvtheta)

    nxy = (xy[0] + l * math.sin(ntheta), xy[1] + l * math.cos(ntheta))

    nvxy = (v * math.sin(nvtheta), v * math.cos(nvtheta))

    return nxy, nvxy
コード例 #6
0
ファイル: dc_simulation.py プロジェクト: YuriCat/AyumuCurling
def calc_vxy_by_xylvw(oxy, xy, v, w):
    l = dc.calc_r(oxy, xy)
    R = calc_r_by_v(v)
    r = calc_r_by_lv(l, v)

    cos_alpha = ((l ** 2) + (R ** 2) - (r ** 2)) / (2 * l * R)
    alpha = math.acos(cos_alpha)
    #print("alpha = ", alpha)
    #print(oxy, xy)
    #print(dc.calc_th(oxy, xy))
    if w < 0:
        alpha = -alpha
    vtheta = calc_vtheta_by_theta(dc.calc_th(oxy, xy) + alpha, w)
    #print("vtheta = ", vtheta)
    return np.matmul(rotationMatrix(-vtheta), (0, v))
コード例 #7
0
ファイル: est_learn_xgb.py プロジェクト: YuriCat/AyumuCurling
    for ph in range(N_PHASES):
        for i in range(phase_data_num[ph]):
            sl = shot_logs[phase_index_vector[ph][i]]

            board_vector[ph][i][0] = sl['end']
            board_vector[ph][i][1] = sl['rscore']

            for n in range(dc.N_STONES):

                st = sl['previous_stone'][n]
                bs = 2 + n * 4

                #board_vector[ph][i][bs + 0] = st[0]
                #board_vector[ph][i][bs + 1] = st[1]
                board_vector[ph][i][bs + 0] = dc.calc_r(dc.XY_TEE, st)
                board_vector[ph][i][bs + 1] = dc.calc_th(dc.XY_TEE, st)
                board_vector[ph][i][bs + 2] = dc.calc_r(dc.XY_THROW, st)
                board_vector[ph][i][bs + 3] = dc.calc_th(dc.XY_THROW, st)

            #sc = dc.count_score_a(sl['previous_stone'])
            sc = sl['escore']

            sc_index = dc.StoIDX(sc)
            score_vector[ph][i] = sc_index
            score_vector_sum[sc_index] += 1  # 事前解析

    print("number of used shot-logs = %d" % data_num)

    test_rate = 0.2
    test_num = []
    train_num = []