Skip to content

Instantly share code, notes, and snippets.

@jeanmidevacc
Created June 25, 2024 09:57
Show Gist options
  • Save jeanmidevacc/309f2cd07ecb6b52f6ea9227f6289bf3 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/309f2cd07ecb6b52f6ea9227f6289bf3 to your computer and use it in GitHub Desktop.
suika_make_Action
if time.time() - last_checked > 2:
step += 1
# Update the last checked time
last_checked = time.time()
particle_states = get_particles_state(handler.data["particles"])
score = handler.data["score"]
# Set the next particle's x position before releasing
observation = {
"particle_states" : particle_states,
"next_particle" : next_particle.n,
"score" : score,
"timestamp" : datetime.utcnow().timestamp()
}
# Get the action
action = agent.get_action(observation)
next_particle.set_x(action)
particles.append(next_particle.release(space, shape_to_particle))
# Log the state
state = observation
state["step"] = step
state["action"] = action
buffer.append(state)
wait_for_next = NEXT_DELAY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment