Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pufferlib/config/ocean/vision_test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[base]
package = ocean
env_name = puffer_vision_test
policy_name = Policy
rnn_name = Recurrent

[env]
num_envs = 4096

[train]
total_timesteps = 150_000_000
adam_beta1 = 0.9051396950168318
adam_beta2 = 0.9998075206648028
adam_eps = 6.080590274937272e-8
anneal_lr = 1
batch_size = auto
bptt_horizon = 64
clip_coef = 0.18136589604817419
ent_coef = 0.008771869770071427
gae_lambda = 0.852233401446272
gamma = 0.9937244196032619
learning_rate = 0.013637100389343416
max_grad_norm = 3.8161147569794194
max_minibatch_size = 32768
minibatch_size = 32768
optimizer = muon
prio_alpha = 0.6199253864227026
prio_beta0 = 0.835222519905636
vf_clip_coef = 0.1
vf_coef = 1.304631362812606
vtrace_c_clip = 1.4932276946661736
vtrace_rho_clip = 0.45768721432684095
1 change: 1 addition & 0 deletions pufferlib/ocean/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def make_multiagent(buf=None, **kwargs):
'asteroids': 'Asteroids',
'whisker_racer': 'WhiskerRacer',
'spaces': make_spaces,
'vision_test': 'VisionTest',
'multiagent': make_multiagent,
}

Expand Down
15 changes: 15 additions & 0 deletions pufferlib/ocean/vision_test/binding.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "vision_test.h"

#define Env VisionTest
#include "../env_binding.h"

static int my_init(Env* env, PyObject* args, PyObject* kwargs) {
return 0;
}

static int my_log(PyObject* dict, Log* log) {
assign_to_dict(dict, "episode_length", log->episode_length);
assign_to_dict(dict, "score", log->score);
assign_to_dict(dict, "n", log->n);
return 0;
}
36 changes: 36 additions & 0 deletions pufferlib/ocean/vision_test/vision_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "raylib.h"
#include "rcamera.h"
#include "raymath.h"
#include "vision_test.h"
#include "puffernet.h"

int main(void) {
VisionTest env = {};

env.observations = (uint8_t*)calloc(3*64 + 1, sizeof(uint8_t)); // Alloc our 16x16 window compressed to float
env.actions = (int*)calloc(5, sizeof(int));
env.rewards = (float*)calloc(1, sizeof(float));
env.terminals = (unsigned char*)calloc(1, sizeof(unsigned char));

c_reset(&env);
c_render(&env);
while (!WindowShouldClose()) {
if (IsKeyDown(KEY_LEFT_SHIFT)) {
env.actions[0] = 0;
if (IsKeyDown(KEY_W)) { env.actions[0] = S_UP; }
else if (IsKeyDown(KEY_S)) { env.actions[0] = S_DOWN; }
else if (IsKeyDown(KEY_A)) { env.actions[0] = S_LEFT; }
else if (IsKeyDown(KEY_D)) { env.actions[0] = S_RIGHT; }
} else {
env.actions[0] = rand() % 5;
}

c_step(&env);
c_render(&env);
}
free(env.observations);
free(env.actions);
free(env.rewards);
free(env.terminals);
c_close(&env);
}
Loading