The program when completed will aim to use AI to get the quickest possible time. The car can accelerate, brake or move at constant speed. There will be sections throughout the code (which represent corners) where the speed will have to be = to or under a certain value (depending on how tight the corner is) and I want the program to be able to decide when the best moments would be to accelerate, brake and move at constant speed would be.
Is this even possible with python? Could you create a neural network which would progressively get a better time? If so how would I go about doing something like this?
Thanks !
import time
x = 0
def TrackSimulation(distance, speed, acceleration, loopbreak, time1):
while loopbreak == 1:
if x == 1:
acceleration = 9
elif x == 2:
acceleration = -9
elif x == 0:
acceleration = 0
else:
print("Error")
if distance >= 0 and distance < 80:
speed = (speed) + ((acceleration) * 0.1)
distance = (distance) + ((speed) * 0.1)
time1 = time1 + 0.1
print((speed), " M/s")
print((distance), "M")
time.sleep(0.1)
elif distance >= 80 and distance <= 110:
if speed >= 30:
print("Too fast!")
loopbreak = 2
break
else:
print("You are in the speed checker")
speed = (speed) + ((acceleration) * 0.1)
distance = (distance) + ((speed) * 0.1)
time1 = time1 + 0.1
print((speed), " M/s")
print((distance), "M")
time.sleep(0.1)
elif distance >= 110 and distance < 200:
speed = (speed) + ((acceleration) * 0.1)
distance = (distance) + ((speed) * 0.1)
time1 = time1 + 0.1
print((speed), " M/s")
print((distance), "M")
time.sleep(0.1)
elif distance >= 200:
print("race over")
finaltime = round((time1), 3)
print("This was your time,", (finaltime))
loopbreak = 2
break