该程序完成后将旨在使用人工智能来获得尽可能快的时间。汽车可以加速、制动或匀速行驶。整个代码中都会有一些部分(代表拐角),其中速度必须等于或低于某个值(取决于拐角的紧密程度),我希望程序能够决定最佳时刻的时间是加速,制动和匀速移动将是。
这甚至可以用python吗?你能创建一个逐渐获得更好时间的神经网络吗?如果是这样,我将如何去做这样的事情?
谢谢 !
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