本文整理汇总了Python中vector.Vector.randomUnitCircle方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.randomUnitCircle方法的具体用法?Python Vector.randomUnitCircle怎么用?Python Vector.randomUnitCircle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector.Vector
的用法示例。
在下文中一共展示了Vector.randomUnitCircle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mutateAt
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import randomUnitCircle [as 别名]
def mutateAt(self, index):
result = False
blob = self.blobs[index]
newBlob = blob.clone()
newBlob.radius += 1
if not self.validate(newBlob):
for i in range(5):
offset = Vector.randomUnitCircle() * random()*i
newBlob.pos += offset
if self.validate(newBlob):
result = True
break
else:
result = True
if not result and random() > 0.5:
newBlob.radius -= 1
for i in range(5):
offset = Vector.randomUnitCircle() * random()*i
if self.validate(newBlob):
result = True
if result:
self.blobs[index] = newBlob
return result
示例2: spawn
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import randomUnitCircle [as 别名]
def spawn(self):
if len(self.blobs) > 0:
randomBlob = choice(self.blobs)
pos = randomBlob.pos + (Vector.randomUnitCircle() * randomBlob.radius * 2) * random()
else:
pos = Vector(random() * self.screenDim[0], random() * self.screenDim[1])
self.spawnAt(pos)
示例3: spawn
# 需要导入模块: from vector import Vector [as 别名]
# 或者: from vector.Vector import randomUnitCircle [as 别名]
def spawn(self):
x = choice(range(self.screenDim[0]))
y = choice(range(self.screenDim[1]))
pos = Vector(x,y)
if not self.isSet(pos):
self.motives.append(Motive(pos, Vector.randomUnitCircle(), choice([MotiveType.Car, MotiveType.Pedestrian])))