+
+ 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;
+ sokoban_screen *r;
+ for(r=screen; r != NULL; r = (sokoban_screen *)(r->hh.next)){
+ switch(r->tile){
+ case FREE: //001
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ break;
+ case WALL: //000
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ break;
+ case BOX: //010
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ break;
+ case TARGET: //011
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ break;
+ case AGENT: //101
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ break;
+ case TARGAGENT: //110
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ break;
+ case TARGBOX: //100
+ st_enc[tile_index] = 1;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ st_enc[tile_index] = 0;
+ tile_index++;
+ break;
+ }
+ }
+ s = sylvan_cube(varset, st_enc);
+ fullState->bdd = s;
+ printf("Initial state encoded\n");
+ return fullState;
+}
+
+int
+test_relprod()
+{
+ LACE_ME;
+
+ BDDVAR vars[] = {0,2,4};
+ BDDVAR all_vars[] = {4,5};
+
+ BDDSET vars_set = sylvan_set_fromarray(vars, 3);
+ BDDSET all_vars_set = sylvan_set_fromarray(all_vars, 2);
+
+ BDD s, t, next, prev;
+ BDD zeroes, ones;
+
+ // transition relation: 000 --> 111 and !000 --> 000
+ t = sylvan_false;
+ //t = sylvan_union_cube(t, all_vars_set, ((uint8_t[]){0,1,0,1,0,1}));
+ //t = sylvan_union_cube(t, all_vars_set, ((uint8_t[]){1,0,2,0,2,0}));
+ //t = sylvan_union_cube(t, all_vars_set, ((uint8_t[]){2,0,1,0,2,0}));
+ t = sylvan_union_cube(t, all_vars_set, ((uint8_t[]){1,0}));
+
+ s = sylvan_cube(vars_set, (uint8_t[]){0,0,1});
+ zeroes = sylvan_cube(vars_set, (uint8_t[]){0,0,0});
+ ones = sylvan_cube(vars_set, (uint8_t[]){0,0,1});
+
+ next = sylvan_relnext(s, t, all_vars_set);
+ prev = sylvan_relprev(t, next, all_vars_set);
+ if (next == zeroes) printf("Pass 1\n");
+ if (prev == ones || prev == zeroes) printf("Pass 2\n");
+
+ return 0;
+}
+
+BDD encode_rel(sokoban_screen *screen)
+{
+ int tile_count = 0;
+ BDD t = sylvan_false;
+ BDDVAR *relvars;
+ uint8_t *rel_enc;
+
+ bimap *bm = create_bimap_helper(screen);
+ int x = 0;
+ int y = 0;
+ bddvar_xy_map *bddxy = NULL;
+ tmp_scr *screen = NULL;
+ tmp_scr_d *screen = NULL;
+ tmp_scr_g *screen = NULL;
+
+ //left relation
+ for (unsigned int i = 0; i < HASH_COUNT(screen); i++){
+ printf("i:%d\n", i);
+ bddxy = getbdd(i*3, bm->t);
+ x = bddxy->value.x;
+ y = bddxy->value.y;
+ if (check_space(x, y, LEFT, 1, bm) == 0){
+ tmp_scr = get_coord(x, y, screen);
+ if (tmp_scr->tile == AGENT){
+
+ }
+ if (tmp_scr->tile == TARGAGENT){
+
+ }
+ }
+ else if (check_space(x, y, LEFT, 1, bm) == 1 && check_space(x, y, LEFT, 2, bm) == 0){
+ tmp_scr = get_coord(x, y, screen);
+ tmp_scr_d = get_coord(x - 1, y, screen);
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && (tmp_scr_d->tile == BOX || tmp_scr_d->tile == TARGBOX)){
+ //can't move
+ }
+ if (tmp_scr->tile == TARGAGENT && (tmp_scr_d->tile == BOX || tmp_scr_d->tile == TARGBOX)){
+ //can't move
+ }
+ }
+ else if (check_space(x, y, LEFT, 1, bm) == 1 && check_space(x, y, LEFT, 2, bm) == 1){
+ tmp_scr = get_coord(x, y, screen);
+ tmp_scr_d = get_coord(x - 1, y, screen);
+ tmp_scr_g = get_coord(x - 2, y, screen);
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d-> tile == BOX && (tmp_scr_g->tile == BOX || tmp_scr_g == TARGBOX)){
+ //can't move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d-> tile == BOX && (tmp_scr_g->tile == BOX || tmp_scr_g == TARGBOX)){
+ //can't move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == BOX && tmp_scr_g->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == TARGBOX && tmp_scr_g->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == BOX && tmp_scr_g->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == AGENT && tmp_scr_d->tile == TARGBOX && tmp_scr_g->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == BOX && tmp_scr_g->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == TARGBOX && tmp_scr_g->tile == FREE){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == BOX && tmp_scr_g->tile == TARGET){
+ //can move
+ }
+ if (tmp_scr->tile == TARGAGENT && tmp_scr_d->tile == TARGBOX && tmp_scr_g->tile == TARGET){
+ //can move
+ }
+ }
+ printf("x:%d y:%d\n", x, y);
+ }
+
+ //up relation
+
+ //right relation
+
+ //down relation
+
+ return sylvan_true;