nice'
[mc1516pa.git] / modelchecker / sokoban.c
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #include "sokoban.h"
5
6 //Still need to remove outside walls and unreachable places.
7 struct sokoban_screen *parse_screen(FILE *stream){
8 int buffer, x, y;
9 x = 0;
10 y = 0;
11 struct sokoban_screen *head, *current;
12 head = NULL;
13 while((buffer = fgetc(stream)) != EOF){
14 if (buffer == '\n'){
15 x = 0;
16 y++;
17 }
18 else {
19 current = (struct sokoban_screen *)malloc(sizeof(struct sokoban_screen));
20 current->next = head;
21 switch(buffer) {
22 case ' ' : current->tile = FREE; break;
23 case '@' : current->tile = AGENT; break;
24 case '.' : current->tile = TARGET; break;
25 case '#' : current->tile = WALL; break;
26 case '$' : current->tile = BOX; break;
27 case '*' : current->tile = TARGBOX; break;
28 case '+' : current->tile = TARGAGENT; break;
29 default: return NULL;
30 }
31 current->x = x;
32 current->y = y;
33 x++;
34 head = current;
35 }
36 }
37 return head;
38 }