@@ -24,23 +24,23 @@ typedef struct {
2424 float score ; // Recommended unnormalized single real number perf metric
2525 float episode_return ; // Recommended metric: sum of agent rewards over episode
2626 float episode_length ; // Recommended metric: number of steps of agent episode
27- // Any extra fields you add here may be exported to Python in binding.c
27+ // Any extra fields you add here may be exported in binding.c
2828 float n ; // Required as the last field
2929} Log ;
3030
3131// Required that you have some struct for your env
32- // Recommended that you name it the same as the env file
3332typedef struct {
3433 Log log ; // Required field. Env binding code uses this to aggregate logs
3534 unsigned char * observations ; // Required. You can use any obs type, but make sure it matches in Python!
36- double * actions ; // Required. double* for new API
35+ float * actions ; // Required
3736 float * rewards ; // Required
3837 float * terminals ; // Required
3938 int num_agents ;
4039 int size ;
4140 int tick ;
4241 int r ;
4342 int c ;
43+ unsigned int rng ;
4444} Squared ;
4545
4646void add_log (Squared * env ) {
@@ -61,7 +61,7 @@ void c_reset(Squared* env) {
6161 env -> tick = 0 ;
6262 int target_idx = 0 ; // Deterministic for testing
6363 do {
64- target_idx = rand ( ) % tiles ;
64+ target_idx = rand_r ( & env -> rng ) % tiles ;
6565 } while (target_idx == tiles /2 );
6666 env -> observations [target_idx ] = TARGET ;
6767}
@@ -70,7 +70,7 @@ void c_reset(Squared* env) {
7070void c_step (Squared * env ) {
7171 env -> tick += 1 ;
7272
73- int action = env -> actions [0 ];
73+ int action = ( int ) env -> actions [0 ];
7474 env -> terminals [0 ] = 0 ;
7575 env -> rewards [0 ] = 0 ;
7676
0 commit comments