git.haldean.org grandmaster / 0b9ad15
add state parent pointers Haldean 3 years ago
3 changed file(s) with 7 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3030 struct move *move;
3131 size_t n_children;
3232 struct state_node **children;
33 struct state_node *parent;
3334 };
3435
3536 struct game {
3434 gt->states[0] = calloc(1, sizeof(struct state_node));
3535 gt->states[0]->n_children = 0;
3636 gt->states[0]->children = NULL;
37 gt->states[0]->parent = NULL;
3738 gt->states[0]->move = calloc(1, sizeof(struct move));
3839 get_root(gt->states[0]->move);
3940 }
120121 gt->states[i]->move = move;
121122 gt->states[i]->n_children = 0;
122123 gt->states[i]->children = NULL;
124 gt->states[i]->parent = game->current;
123125
124126 new_children = realloc(
125127 game->current->children,
5050 fprintf(stderr, "expected 4 states, got %lu\n", gt->n_states);
5151 return 1;
5252 }
53 if (gt->games[g1]->current->parent != gt->games[g2]->current) {
54 fprintf(stderr, "g1's parent should be g2\n");
55 return 1;
56 }
5357
5458 if (quiet) {
5559 fprintf(stderr, "OK\n");