2022-01-09 00:12:46 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "maze.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2022-01-21 20:53:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
int solve_maze(char* maze,int size){
|
|
|
|
|
|
|
|
//int end = size*size;
|
|
|
|
int actualPos = 0;
|
|
|
|
maze[actualPos]='*';
|
|
|
|
|
|
|
|
while(actualPos != size*size-1){
|
|
|
|
//printf("acpos: %d\n", actualPos);
|
|
|
|
//Pohyb dole
|
|
|
|
if(actualPos < (size*size-size) && maze[actualPos+size]==' '){
|
|
|
|
printf("dole\n");
|
|
|
|
maze[actualPos+size]='*';
|
|
|
|
actualPos+=size;
|
|
|
|
printf("acpos: %d\n", actualPos);
|
2022-01-09 00:12:46 +00:00
|
|
|
continue;
|
2022-01-21 20:53:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Pohyb vpravo
|
|
|
|
if(maze[actualPos+1]==' '){
|
|
|
|
puts("vpravo");
|
|
|
|
maze[actualPos]='*';
|
|
|
|
actualPos++;
|
2022-01-09 00:12:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-01-21 20:53:46 +00:00
|
|
|
//Pohyb hore
|
|
|
|
/* if(maze[actualPos-size]==' ' && actualPos-size != 0){
|
|
|
|
maze[actualPos-size]='*';
|
|
|
|
actualPos-=size;
|
|
|
|
continue;
|
|
|
|
}*/
|
2022-01-09 00:12:46 +00:00
|
|
|
|
2022-01-21 20:53:46 +00:00
|
|
|
/*
|
|
|
|
//Pohyb vlavo
|
|
|
|
if(maze[actualPos-1]==' '){
|
|
|
|
maze[actualPos]='*';
|
|
|
|
actualPos--;
|
|
|
|
continue;
|
2022-01-09 00:12:46 +00:00
|
|
|
}
|
2022-01-21 20:53:46 +00:00
|
|
|
*/
|
2022-01-09 00:12:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-21 20:53:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-09 00:12:46 +00:00
|
|
|
|
|
|
|
|
2022-01-21 20:53:46 +00:00
|
|
|
|
|
|
|
return 1;
|
2022-01-09 00:12:46 +00:00
|
|
|
}
|