How would I implement coordinates and moving through the maze after user selects starting location?

Alright so I've been making some good progress with the program I am working on and wanted to know how would I set up the coordinates the maze can be solved once the user inputs the choice of starting location. I could either create coordinates within the same file or create a class and do it there which would be easier or better?

here's my code if you want to check everything:

//Comments are used to understand the code as well as others reading it
#include <iostream>
#include<string>
#include<vector>
#include<fstream>
#include<cstdlib>


using namespace std;
char wall = '1';
bool foot_paths = true;
char INVALID = '1';
bool Start = false;
void options(int, int);
const int ROW = 3;
const int COLUMN = 6;
//bool solution();
//int coord(int x, int y);


//checks to see if the starting point is valid, if they start on a hedge
bool pointValidation(int row, int column) {

return (row >= 0) && (row < ROW) &&
(column >= 0) && (column < COLUMN);
}

void showMaze(char array[ROW][COLUMN]) {
//this is for printing the maze
for (int x = 0; x < ROW; x++) {
for (int y = 0; y < COLUMN; y++) {


cout << array[x][y];

}
cout << endl;
}
}

//function that reads the Maze.txt file into an array
void loadMaze(char array[ROW][COLUMN]) {

fstream infile;
string mazeLine;

infile.open("Maze.txt");
if (infile.is_open())
{

for (int i = 0; i < ROW; i++) {
infile >> mazeLine;
for (int j = 0; j < COLUMN; j++)
{
array[i][j] = mazeLine[j];
}
}
infile.close();
}

}
//Check to see if the user input was valid
void options(char Maze[ROW][COLUMN]) {

int inputRow, inputCol;

cout << "Enter ROW #(1 - 3)" << endl;
cin >> inputRow;
inputRow -= 1;
cout << "Enter COLUMN # (1 - 6)" << endl;
cin >> inputCol;
inputCol -= 1;

while ((inputRow < 0 || inputRow > ROW - 1) || (inputCol < 0 || inputCol > COLUMN - 1)) {

if (inputRow < 0 || inputRow > ROW - 1)
{
cout << "Enter ROW #(1 - 3)" << endl;
cin >> inputRow;
inputRow -= 1;
}
else if (inputCol < 0 || inputCol > COLUMN - 1)
{
cout << "Enter COLUMN # (1 - 6)" << endl;
cin >> inputCol;
inputCol -= 1;
}
pointValidation(inputRow, inputCol);

}
//Maze[0][1] = inputRow;
//Maze[1][0] = inputCol;
//coord[0] = inputRow;
//coord[1] = inputCol;

while (Maze[inputRow][inputCol] == INVALID)
{
cout << "You can't start here, its a fence" << "\n Try again" << endl;
cout << "Enter ROW #(1 - 3)" << endl;
cin >> inputRow;
inputRow -= 1;
cout << "Enter COLUMN # (1 - 6)" << endl;
cin >> inputCol;
inputCol -= 1;

if (inputRow < 0 || inputRow > ROW - 1) {
cout << "Enter ROW #(1 - 3)" << endl;
cin >> inputRow;
inputRow -= 1;

}
else if (inputCol < 0 || inputCol > COLUMN - 1) {

cout << "Enter COLUMN # (1 - 6)" << endl;
cin >> inputCol;
inputCol -= 1;

}



pointValidation(inputRow, inputCol);

}
if (Maze[inputRow][inputCol] == '0')
{

Maze[inputRow][inputCol] = '*';
showMaze(Maze);
}
else if (Maze[inputRow][inputCol] == 'E')
{
Maze[inputRow][inputCol] = '*';
showMaze(Maze);
cout << "solution found!" << endl;
}
if ((inputRow <= 0 || inputRow >= ROW - 1) && (inputCol <= 0 || inputCol >= COLUMN - 1)) {
cout << "Row: " << inputRow+1 << "\n" << "Column: " << inputCol+1 << endl;
//Maze[0][1] = inputRow;
//Maze[1][0] = inputCol;
//coord[0] = inputRow;
//coord[1] = inputCol;

}
//coord[0] = inputRow;
//coord[1] = inputCol;
//Maze[inputRow][inputCol] = Start;

}


int main() {
char Maze[ROW][COLUMN];
loadMaze(Maze);
showMaze(Maze);

options(Maze);








system("PAUSE");//pauses the program from flashing off quickly
return 0;//excution went through fine
}


Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/

The code without proper indention is hard to read.

I could either create coordinates within the same file or create a class and do it there which would be easier or better?
What is the purpose of this coordinates?

Whether a class is better depends on your design. Currently you have three functions with the sole purpose to deal with the maze, hence it would be an idea to make a maze class.
Topic archived. No new replies allowed.