Created
June 25, 2024 09:57
-
-
Save jeanmidevacc/309f2cd07ecb6b52f6ea9227f6289bf3 to your computer and use it in GitHub Desktop.
suika_make_Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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