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
|
#include <iostream>
#include <iomanip>
using namespace std;
const int SIZE = 10;
void createMaze(int maze [][SIZE], int& robotRow, int& robotColumn);
void displayMaze(int maze [][SIZE], int robotRow, int robotColumn);
void randomMove(int maze [][SIZE], int& robotRow, int& robotColumn);
void smartMove(int maze [][SIZE], int& robotRow, int& robotColumn);
int main()
{
int robotRow, robotColumn;
int maze[SIZE][SIZE];
createMaze(maze, robotRow, robotColumn);
displayMaze(maze, robotRow, robotColumn);
}
void createMaze(int maze [][SIZE], int& robotRow, int& robotColumn)
{
robotRow = 2;
robotColumn = 1;
int temp[SIZE][SIZE] =
{
{ 1,1,1,1,1,1,1,1,1,1 },
{ 3,0,0,0,0,0,0,0,0,1 },
{ 1,1,0,1,1,1,1,1,1,1 },
{ 1,0,0,0,0,0,0,0,0,1 },
{ 1,1,1,1,0,1,0,1,0,1 },
{ 1,0,0,0,0,1,0,1,1,1 },
{ 1,0,1,0,1,1,0,0,0,1 },
{ 1,0,1,0,0,1,1,1,1,1 },
{ 1,0,0,1,0,0,0,0,0,2 },
{ 1,1,1,1,1,1,1,1,1,1 }
};
for (int row = 0; row < SIZE; row++)
for (int col = 0; col < SIZE; col++)
maze[row][col] = temp[row][col];
}
void displayMaze(int maze [][SIZE], int robotRow, int robotColumn)
{
for (int row = 0; row < SIZE; row++)
{
for (int col = 0; col < SIZE; col++)
{
switch (maze[row][col])
{
case 0:
cout << '#';
break;
case 1:
cout << ' ';
break;
case 2:
cout << '&';
break;
}
cout << maze[row][col] << " ";
}
cout << endl;
}
}
void randomMove(int maze [][SIZE], int& robotRow, int& robotColumn)
{
}
void smartMove(int maze [][SIZE], int& robotRow, int& robotColumn)
{
}
| |