From cea7a7530da65655771fb496ed7bd52c4f862f57 Mon Sep 17 00:00:00 2001 From: Theo Brockmann <theo.brockmann@stud.hs-bochum.de> Date: Sat, 20 Mar 2021 09:19:37 +0000 Subject: [PATCH] Update main_test.py --- main_test.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/main_test.py b/main_test.py index 5ee28e3..1ff2560 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']) -- GitLab