1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#include <stack>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
const char *playerMarker = "S"; //What player is marked as on board
const char *wallMarker = "X"; //What the walls are marked as on board
const char *endMarker = "E"; //What the end is marked as on the board
//Vector for player moves
vector<pair<int, int>> playerMovesVect;
// pair and stack for player location
std::pair <int, int> pos;
std::stack<std::pair <int, int> > playerLocation;
//pair for endLocation
std::pair <int, int> endPos;
const int SIZE = (15 * 15);
//Variables to hold pair numbers
int pair1;
int pair2;
//Row * Coloumn
char arrMaze [SIZE][SIZE] =
{
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
/*0*/ {'X', 'X', 'X', 'X', 'X', 'X','X', 'X', 'X','X', 'X', 'X','X', 'X', 'X'},
/*1*/ {'X', 'S', 'X', 'X', 'X', 'X','X', 'X', 'X',' ', 'X', 'X','X', 'X', 'X'},
/*2*/ {'X', ' ', ' ', ' ', ' ', 'X','X', 'X', 'X',' ', 'X', ' ','X', 'X', 'X'},
/*3*/ {'X', 'X', ' ', 'X', 'X', 'X','X', 'X', 'X',' ', 'X', ' ','X', 'X', 'X'},
/*4*/ {'X', ' ', ' ', 'X', 'X', 'X','X', 'X', ' ',' ', ' ', ' ','X', 'X', 'X'},
/*5*/ {'X', ' ', 'X', 'X', 'X', 'X','X', ' ', ' ','X', 'X', 'X','X', 'X', 'X'},
/*6*/ {'X', ' ', 'X', ' ', 'X', 'X','X', ' ', ' ',' ', 'X', 'X','X', 'X', 'X'},
/*7*/ {'X', ' ', 'X', ' ', 'X', 'X','X', ' ', 'X',' ', 'X', 'X','X', 'X', 'X'},
/*8*/ {'X', ' ', ' ', ' ', 'X', 'X','X', ' ', 'X',' ', 'X', ' ',' ', ' ', 'X'},
/*9*/ {'X', 'X', ' ', ' ', 'X', 'X','X', ' ', 'X',' ', 'X', ' ','X', ' ', 'X'},
/*0*/ {'X', 'X', ' ', ' ', ' ', ' ',' ', ' ', 'X',' ', 'X', ' ','X', ' ', 'X'},
/*1*/ {'X', 'X', ' ', 'X', 'X', 'X','X', 'X', 'X',' ', 'X', ' ','X', ' ', 'X'},
/*2*/ {'X', 'X', ' ', 'X', 'X', 'X','X', 'X', 'X',' ', ' ', ' ','X', ' ', 'X'},
/*3*/ {'X', 'X', ' ', 'X', 'X', 'X','X', 'X', 'X','X', 'X', ' ','X', 'E', 'X'},
/*4*/ {'X', 'X', 'X', 'X', 'X', 'X','X', 'X', 'X','X', 'X', 'X','X', 'X', 'X'}};
for(int i = 0; i < SIZE; i++)
{
for(int j = 0; j < SIZE; j++)
{
//Find the playerMarker
if (arrMaze[i][j] == *playerMarker)
{
pos.first = i;
pos.second = j;
}
//find exitMarker
else if (arrMaze[i][j] == *endMarker)
{
endPos.first = i;
endPos.second = j;
}
else
{
i++;
j++;
}
}
cout << endPos.first << endPos.second;
}
}
|