Skip to content

Commit

Permalink
fixed bug in state serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ckchow committed May 2, 2015
1 parent 61f6eb5 commit f31e4d3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions soccer.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,26 @@ void flatten_state(int* dest);
*****************************************************************/
/* turn the team state into an array of 48 integers */
void flatten_state(int* dest)
void flatten_state(int* dest)
{
// 12 integers per player
for (int i = 0; i < 4; i++)
{
for (int i = 0; i < 4; i++)
int idx = i * 12;
int j = 0;

dest[idx+j] = team_state[i].x;
j++;
dest[idx+j] = team_state[i].y;
j++;
for (int k = 0; k < 9; k++)
{
int j = 0;
dest[i+j] = team_state[i].x;
j++;
dest[i+j] = team_state[i].y;
dest[idx+j] = team_state[i].neighborhood[k];
j++;
for (int k = 0; k < 9; k++)
{
dest[i+j] = team_state[i].neighborhood[k];
j++;
}
dest[i+j] = team_state[i].ball_direction;
}
dest[idx+j] = team_state[i].ball_direction;
}
}

/*****************************************************************
Expand Down

0 comments on commit f31e4d3

Please sign in to comment.