X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=modelchecker%2Fsokoban.c;h=1abda09b64a5dc24685cfe8b0f4f11ee32778145;hb=bfe9ddb4ffe22c1d8bdd16c39905b226cf122dd9;hp=e302670ca7b8ea6ef88db6a62d207dfc488f22e5;hpb=87a49a20bdeb4fe199dd9a61468d653417b14ae8;p=mc1516pa.git diff --git a/modelchecker/sokoban.c b/modelchecker/sokoban.c index e302670..1abda09 100644 --- a/modelchecker/sokoban.c +++ b/modelchecker/sokoban.c @@ -1,17 +1,38 @@ #include - +#include #include "sokoban.h" + +//Still need to remove outside walls struct sokoban_screen *parse_screen(FILE *stream){ - int buffer; - while((buffer = fgetc(stream)) != EOF){ - printf("%c", buffer); - } - // Alex: - // Screen reading - // - Removing outside walls - // - Bucket fill - // - [tile] - // - tile = structure {int, int, enumtile} - return NULL; -} + int buffer, x, y; + x = 0; + y = 0; + struct sokoban_screen *head, *current; + head = NULL; + while((buffer = fgetc(stream)) != EOF){ + if (buffer == '\n'){ + x = 0; + y++; + } + else { + current = (struct sokoban_screen *)malloc(sizeof(struct sokoban_screen)); + current->next = head; + switch(buffer) { + case ' ' : current->tile = FREE; break; + case '@' : current->tile = AGENT; break; + case '.' : current->tile = TARGET; break; + case '#' : current->tile = WALL; break; + case '$' : current->tile = BOX; break; + case '*' : current->tile = TARGBOX; break; + case '+' : current->tile = TARGAGENT; break; + default: return NULL; + } + current->x = x; + current->y = y; + x++; + head = current; + } + } + return head; + }