Exemple #1
0
def get_r(name):
    r, ti = 0, fc.get_ti(name)
    mid = ti['mid']
    sight = fc.get_car_sight(name)
    if sight[mid[0][1]][mid[0][0]] < 0.5:
        r = -1000
    else:
        r = -np.square(mid[0][0] - len(fc.get_car_sight(name)[0]) / 2)

    #r -= np.square((100-fc.get_velocity(name))/50)
    return r


fc.game_init('FCMAP0.PNG')
fc.add_car('0', (430, 300))
fc.set_car('0', (430, 300), np.pi / 2, 0)
wight = len(fc.get_car_sight('0')[0])
hight = len(fc.get_car_sight('0'))
fc.set_time_speed(1)
fc.start()

ddpg = DDPG.DDPG(10, 1, np.array([np.pi / 3]))
var = np.pi / 3

times = 1

while times:

    break_count = 0
    s, a, r, s_, pointer = [], [], [], [], 0
    wight = len(sight[0])
    hight = len(sight)
    r, ti = 0, fc.get_ti(name)
    mid = ti['mid']

    if sight[mid[0][1]][mid[0][0]] < 0.5:
        r = -35
    else:
        r = -np.abs(mid[0][0] - wight / 2)
    return r


FRAME_SPACING = 20

fc.game_init('FCMAP0.PNG')
fc.add_car('0', (90, 255))
fc.set_car('0', (90, 255), np.pi / 2, 0)
#fc.show_car_sight('0')
wight = len(fc.get_car_sight('0')[0])
fc.set_time_speed(0)

ddpg = MDDPG.DDPG(11, 2, 2, np.array([np.pi / 3, 256]))
var = np.array([np.pi / 3, 100])

times = 1
fc.start()
while times:

    start_time = fc.get_time()
    normal_working = 0
    s, a, r, s_ = [], [], [], []
Exemple #3
0
                            name='target_ctrl',
                            op_name='ctrl_model')

value_model = tfl.regression(value,
                             placeholder=y,
                             optimizer='adam',
                             loss=value_loss,
                             trainable_vars=value_vars,
                             batch_size=64,
                             name='target_value',
                             op_name='value_model')

model = tfl.DNN(tf.concat([ctrl, value], 1))

fc.game_init("FCMAP0.PNG")
fc.add_car("0", (430, 240))
fc.set_car("0", (430, 240), np.pi / 2, 0)
fc.show_car_sight("0")
wight = len(fc.get_car_sight("0")[0])

train_sight = []
train_degree = []
train_velocity = []
train_y = []

degree = 0
velocity = 100

times = 1
fc.set_time_speed(1)
fc.start()