nice'
[mc1516pa.git] / modelchecker / sokoban.c
index e69de29..9d42daf 100644 (file)
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sokoban.h"
+
+//Still need to remove outside walls and unreachable places.
+struct sokoban_screen *parse_screen(FILE *stream){
+       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;
+}