+state *encode_goal(sokoban_screen *screen){
+ LACE_ME;
+
+ BDDVAR vars[HASH_COUNT(screen) * 3];
+ for (uint8_t i = 0; i < HASH_COUNT(screen) * 3; i++){
+ vars[i] = i * 2;
+ }
+
+ uint8_t st_enc[HASH_COUNT(screen) * 3];
+
+ BDDSET varset = sylvan_set_fromarray(vars, HASH_COUNT(screen) * 3);
+ BDD s;
+ state *fullState = NULL;
+ fullState = (state *)malloc(sizeof(state));
+ fullState->vars.varset = varset;
+ fullState->vars.size = HASH_COUNT(screen) * 3;
+ int tile_index = 0;
+ for(sokoban_screen *r=screen; r != NULL; r=r->hh.next){
+ switch(r->tile){
+ case FREE: //001 -> any
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ break;
+ case WALL: //000 -> stays the same
+ st_enc[tile_index++] = 0;
+ st_enc[tile_index++] = 0;
+ st_enc[tile_index++] = 0;
+ break;
+ case BOX: //010 -> any
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ break;
+ case TARGET: //011 -> targbox
+ st_enc[tile_index++] = 1;
+ st_enc[tile_index++] = 0;
+ st_enc[tile_index++] = 0;
+ break;
+ case AGENT: //101 -> any
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ st_enc[tile_index++] = 2;
+ break;
+ case TARGAGENT: //110 -> targbox
+ st_enc[tile_index++] = 1;
+ st_enc[tile_index++] = 0;
+ st_enc[tile_index++] = 0;
+ break;
+ case TARGBOX: //100 -> stays the same
+ st_enc[tile_index++] = 1;
+ st_enc[tile_index++] = 0;
+ st_enc[tile_index++] = 0;
+ break;
+ }
+ }
+ s = sylvan_cube(varset, st_enc);
+ fullState->bdd = s;
+ return fullState;
+}