[英]how do i find the greatest length from a given point and make the program stop after that point with the greatest length hits the middle?
My program makes 30 randomly generated points that spawn from the edge of the map that move towards the center.我的程序制作了 30 个随机生成的点,这些点从地图的边缘向中心移动。 My program works fine, but how would I find the largest length of these points and then say "if the largest length hits the middle, reset?
我的程序运行良好,但是我如何找到这些点的最大长度,然后说“如果最大长度到达中间,则重置?
I just dont know how我只是不知道如何
biggestLength = 0
lengthList = []
after = 1
length = math.sqrt(dx * dx + dy * dy)
lengthList.append(length)
biggestLength = lengthList[0]
if len(lengthList) == 30:
while x < 30:
if lengthList[after] > biggestLength:
lengthList[after] = biggestLength
after += 1
x += 1
lastWaste = lengthList.index(biggestLength)
print (biggestLength)
lengthList = []
列表的最大值可以通过max
获得:
biggestLength = max(lengthList)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.