Created
March 26, 2025 10:56
-
-
Save MX-2000/82816063f085312ddeb5912ec07626cf to your computer and use it in GitHub Desktop.
This file contains 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
void compute_observations(CCpr *env) { | |
for (int i = 0; i < env->num_agents; i++) { | |
Agent *agent = &env->agents[i]; | |
int obs_offset = i * env->obs_size; | |
int r_offset = agent->r - env->vision; | |
int c_offset = agent->c - env->vision; | |
for (int r = 0; r < 2 * env->vision + 1; r++) { | |
for (int c = 0; c < 2 * env->vision + 1; c++) { | |
int grid_idx = (r_offset + r) * env->width + c_offset + c; | |
int obs_idx = obs_offset + r * env->vision_window + c; | |
env->observations[obs_idx] = env->grid[grid_idx]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment