diff --git a/main_test.py b/main_test.py index 5ee28e308b782cfe45529b54ac790c81647dbe94..1ff25601932e32405e15d1fa9f16179c748feb95 100644 --- a/main_test.py +++ b/main_test.py @@ -25,15 +25,28 @@ async def main(): print(observation) print(reward) print(done) + + total_reward = 0 + while done and total_reward > -80 and reward[1] < 50: + # Here could be conditions to determine which actions to take + actions = "accelerate" + # For example: + if observation[2][2] < 4: # observation[2][2] is the sensor to the right and 4 is in meters + actions += "steer_left" + + # Makes 1 step only driving straight + observation, reward, done, info = await env.step(actions, 0.17) + print(observation) + # Obeservation is an array with the following information: + # [speed, steering-angle, [length of all sensors (starting straight and then clockwise around the car)]] + print(reward) + print(done) + + total_reward -= reward[1] + actions = "" - # Makes 1 step only driving straight - observation, reward, done, info = await env.step("accelerate,screen_on", 0.17) - print(observation) - # Obeservation is an array with the following information: - # [speed, steering-angle, [length of all sensors (starting straight and then clockwise around the car)]] - print(reward) - print(done) - + print(total_reward) + try: # Test show Image si.show_image(image_mode,info['thumbnail']['width'],info['thumbnail']['height'],info['thumbnail']['image'])