本文整理汇总了Python中track.Track.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Track.reset方法的具体用法?Python Track.reset怎么用?Python Track.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类track.Track
的用法示例。
在下文中一共展示了Track.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CyclopsEvolver
# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import reset [as 别名]
class CyclopsEvolver(TournamentEvolver):
def __init__(self, popSize, tournSize, nIters):
super().__init__(popSize, tournSize, nIters)
self.track = Track()
self.simDuration = self.track.size * 4
self.startSeed = random.random()
def randomIndividual(self):
nNeurons = 8
return System(nNeurons)
def mutated(self, system):
return self.mutatedPartial(system, 1, 8)
def mutatedPartial(self, system, mean, variance):
sys = system.copy()
#sys.trans += variance / 4 * numpy.random.randn(*sys.trans.shape)
sys.trans *= mean + variance * numpy.random.randn(*sys.trans.shape)
#sys.trans += 1/8 * numpy.random.randn(*sys.trans.shape)
return sys
def fitness(self, system):
return sum(self.fitness1(system, self.startSeed + i) for i in range(64))
def fitness1(self, system, seed):
distances = []
def distanceTracker(track):
rawDist = track.bot.position - track.flag.position
dist = min(rawDist % track.size, (-rawDist) % track.size)
distances.append(dist)
self.simulate(system, distanceTracker, seed)
return -sum(d for d in distances[-self.track.size : ])
def simulate(self, system, watcher, seed=None):
# initialize conditions
self.track.reset(seed)
system.reset()
# simulate
for iteration in range(self.simDuration):
self.track.step(system)
watcher(self.track)
def animate(self, system):
frames = []
def frameCapturer(track):
frames.append(track.drawnState())
self.simulate(system, frameCapturer)#, self.startSeed)
return frames