File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
pufferlib/ocean/slimevolley Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -492,9 +492,12 @@ void abranti_simple_bot(float* obs, float* action) {
492492// Required function
493493void c_step (SlimeVolley * env ) {
494494 env -> rewards [0 ] = 0 ;
495- env -> rewards [1 ] = 0 ;
496495 env -> terminals [0 ] = 0 ;
497- env -> terminals [1 ] = 0 ;
496+ if (env -> num_agents == 2 ){
497+ env -> rewards [1 ] = 0 ;
498+ env -> terminals [1 ] = 0 ;
499+ }
500+
498501 Agent * left = & env -> agents [0 ];
499502 Agent * right = & env -> agents [1 ];
500503 Ball * ball = env -> ball ;
@@ -539,20 +542,26 @@ void c_step(SlimeVolley* env) {
539542 if (right_reward == -1 ){
540543 right -> lives -- ;
541544 env -> rewards [0 ] = 1.0f ;
542- env -> rewards [1 ] = -1.0f ;
545+ if (env -> num_agents == 2 ){
546+ env -> rewards [1 ] = -1.0f ;
547+ }
543548 }
544549 else {
545550 left -> lives -- ;
546551 env -> rewards [0 ] = -1.0f ;
547- env -> rewards [1 ] = 1.0f ;
552+ if (env -> num_agents == 2 ){
553+ env -> rewards [1 ] = 1.0f ;
554+ }
548555 }
549556 }
550557 agent_update_state (left , ball , right );
551558 agent_update_state (right , ball , left );
552559
553560 if (env -> tick > MAX_TICKS || left -> lives <= 0 || right -> lives <= 0 ){
554561 env -> terminals [0 ] = 1 ;
555- env -> terminals [1 ] = 1 ;
562+ if (env -> num_agents == 2 ){
563+ env -> terminals [1 ] = 1 ;
564+ }
556565 env -> log .perf = (left -> lives - right -> lives + 5.0f ) / 10.0f ; // normalize to 0-1
557566 env -> log .score = (float )(left -> lives - right -> lives );
558567 env -> log .episode_return = (5.0f - right -> lives );
You can’t perform that action at this time.
0 commit comments