#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
struct direction
{
int xD;
int yD;
};
direction Up, Do, Le, Ri;
Up.xD = 0;
Up.yD = -1;
Do.xD = 0;
Do.yD = 1;
Le.xD = -1;
Le.yD = 0;
Ri.xD = 1;
Ri.yD = 0;
char maze[100][100];
char solvedMaze[100][100];
void clearMaze(char maze[][100]);
void readMaze(char maze[][100], int &rows, int &columns, string filename)
// Reads the maze from the text file with the name passed to the function
{
ifstream inputMaze;
inputMaze.open(filename.c_str());
inputMaze >> rows >> columns;
string templine;
int temprow, tempcolumn;
temprow = 0;
getline(inputMaze, templine);
// Clears the end line character from the maze
clearMaze(maze);
while(!inputMaze.eof())
{
getline(inputMaze, templine);
for(tempcolumn=0; tempcolumn < columns; tempcolumn++)
{
maze[temprow][tempcolumn] = templine[tempcolumn];
}
temprow++;
}
inputMaze.close();
}
void clearMaze(char maze[][100])
// Sets every character in the maze to a wall
// Extra walls outside of the maze will not effect the solving of the maze
// Since we are given the dimensions of the maze, it will not affect the output
// of the maze, either.
{
int i, j;
for(i=0; i<100; i++)
{
for(j=0; j<100; j++)
{
maze[i][j] = '*';
}
}
}
void displayMaze(char maze[][100], int rows, int columns)
// Displays the maze
{
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < columns; j++)
{
cout << maze[i][j];
}
cout << endl;
}
}
void makeMove(char maze[][100], direction direct, int &X, int &Y)
{
// I will finish this later >.>
}
void solveMaze(char maze[][100], int rows, int columns)
{
int X, Y;
X = 1;
Y = 1;
direction currentDirection = Ri;
// We start at (1,1), or maze[1][1]
//
// We wish to get to (columns - 1, rows - 1), or maze[rows-1][columns-1]
while(X != (columns - 1) && Y != (rows - 1))
{
makeMove(maze, currentDirection, X, Y);
}
}
int main()
{
int rows, columns;
string firstline, filename;
filename = "maze1.txt";
readMaze(maze, rows, columns, filename);
displayMaze(maze, rows, columns);
char cc;
cin >> cc;
return 0;
}