Skip to content

Instantly share code, notes, and snippets.

@gsurma
Created December 23, 2018 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsurma/eff480149e9a045c57478ff8c3ecd488 to your computer and use it in GitHub Desktop.
Save gsurma/eff480149e9a045c57478ff8c3ecd488 to your computer and use it in GitHub Desktop.
def _gameplay_for_chromosome(self, chromosome, env):
self.run += 1
self.logger.add_run(self.run)
self.model.set_weights(chromosome)
state = env.reset()
score = 0
while True:
action = self._predict(state)
state_next, reward, terminal, info = env.step(action)
score += np.sign(reward)
state = state_next
if terminal:
self.logger.add_score(score)
return score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment