#include <iostream>
#include <ctime>
#include <cstdlib>
#include <windows.h>
using namespace std;
unsigned long stepInt = 0;
const int size = 40;
int arraybox[size][size]={177,177,177,177,177,177,177,177,177,177,177,177, 177,177,177,177,177,177,177,177,177,177,177,177,17 7,177,177,177,177,177,177,177,177,177,177,177,177, 177,177,177,
177, 0,0,0,177,0,0,0,0,0,0,0,177,0,0,0,177,0,0,0,177,0, 0,0,0,0,177,0,0,0,177,0,0,0,0,0,0,0,0,177,
177,177,177,0,0,0,177,177,177,177,177,0,0,0,177,0, 177,0,177,0,177,0,177,177,177,177,177,0,177,0,177, 0,177,177,177,177,177,177,0,177,
177,0,0,0,177,0,177,0,0,0,177,177,177,177,177,0,0, 0,177,0,177,0,177,0,0,0,177,0,177,0,0,0,177,0,0,0, 0,177,0,177,
177,0,177,177,0,0,0,0,177,0,177,0,0,0,177,177,177, 177,177,0,177,0,0,0,177,0,177,0,177,177,177,177,17 7,0,177,0,0,177,0,177,
177,0,0,177,0,177,177,177,177,0,0,0,177,0,0,177,0, 177,0,0,177,0,177,177,0,0,177,0,0,0,0,0,177,0,177, 0,0,177,0,177,
177,177,177,177,0,0,0,0,177,177,177,177,177,177,0, 177,0,0,0,177,177,0,177,0,0,177,177,177,177,177,17 7,0,177,0,177,0,177,177,0,177,
177,0,0,0,0,177,177,0,0,0,0,0,0,177,0,177,0,177,17 7,177,0,0,177,0,177,177,0,0,0,177,177,0,177,0,177, 0,0,0,0,177,
177,0,177,177,177,177,177,177,177,177,177,177,0,17 7,177,177,177,177,177,0,0,177,177,0,177,0,0,177,0, 177,0,0,177,0,177,177,177,177,177,177,
177,0,177,0,0,0,0,0,0,0,0,177,0,177,0,0,0,0,177,0, 177,177,0,0,177,0,177,177,0,177,0,177,177,0,0,0,0, 0,0,177,
177,0,177,0,177,177,177,177,177,177,0,177,0,177,0, 177,177,0,177,0,177,0,0,177,177,0,177,0,0,177,0,0, 177,0,177,177,177,177,0,177,
177,0,177,0,177,0,0,0,0,177,0,177,0,177,0,0,177,0, 177,0,177,0,177,177,0,0,177,0,177,177,177,0,177,0, 177,0,0,0,0,177,
177,0,177,0,177,0,177,177,0,177,0,177,0,177,177,0, 177,0,177,0,177,0,177,0,0,177,177,0,0,177,0,0,177, 0,177,0,177,177,177,177,
177,0,177,0,177,0,0,177,0,177,0,177,0,0,0,0,177,0, 0,0,177,0,177,0,177,177,177,177,0,177,0,177,177,0, 177,0,0,0,0,177,
177,0,177,0,177,177,0,177,0,177,0,177,0,177,177,17 7,177,177,177,177,177,0,177,0,177,0,0,0,0,177,0,0, 177,0,177,177,177,177,0,177,
177,0,177,0,0,0,0,177,0,177,0,177,0,0,0,0,0,177,0, 0,0,0,177,0,177,0,177,177,177,177,177,0,177,0,177, 0,0,0,0,177,
177,0,177,177,177,177,177,177,0,177,0,177,177,177, 177,177,0,177,0,177,177,177,177,0,177,0,177,0,0,0, 177,0,177,0,177,0,177,177,177,177,
177,0,0,0,0,0,0,0,0,177,0,177,0,0,0,0,0,177,0,0,0, 0,0,0,177,0,0,0,177,0,0,0,177,0,177,0,0,0,0,177,
177,177,177,177,177,177,177,177,177,177,0,177,0,17 7,177,177,177,177,177,177,177,177,177,177,177,177, 177,177,177,177,177,177,177,177,177,177,177,177,0, 177,
177,0,0,0,0,0,0,0,0,0,0,177,0,177,0,0,0,177,0,0,0, 0,0,0,0,177,0,0,0,0,0,0,0,177,0,0,0,177,0,177,
177,0,177,177,177,177,177,177,177,177,177,177,0,17 7,0,177,0,0,0,177,177,177,177,177,0,177,0,177,177, 177,177,177,0,177,0,177,0,177,0,177,
177,0,177,0,0,0,0,0,0,0,0,177,0,177,0,177,177,177, 177,177,0,0,0,0,0,177,0,177,0,0,0,177,0,177,0,177, 0,0,0,177,
177,0,177,0,177,177,177,177,177,177,0,177,0,177,0, 0,0,177,0,0,0,177,177,177,177,177,0,177,0,177,0,17 7,0,177,0,177,177,177,177,177,
177,0,177,0,177,0,0,0,0,177,0,177,0,177,177,177,0, 177,0,177,177,177,0,0,0,177,0,0,0,177,0,177,0,0,0, 0,0,0,0,177,
177,0,0,0,177,0,177,177,0,177,0,177,0,0,0,0,0,177, 0,0,0,0,0,177,0,177,177,177,177,177,177,177,177,17 7,177,177,177,177,0,177,
177,177,177,177,177,0,177,177,0,177,0,177,177,177, 177,177,177,177,177,177,177,177,177,177,0,0,0,0,0, 177,0,0,0,0,0,0,0,177,0,177,
177,0,0,0,0,0,177,177,0,177,0,177,0,0,0,177,0,0,0, 0,0,0,0,177,177,177,177,177,0,177,0,177,177,177,17 7,177,0,177,0,177,
177,0,177,177,177,177,177,177,0,177,0,177,0,177,0, 177,0,177,177,177,177,177,0,0,0,0,0,177,0,177,0,17 7,0,0,0,177,0,177,0,177,
177,0,0,177,0,0,0,177,0,0,0,177,0,177,0,177,0,177, 0,0,0,177,177,177,177,177,0,177,0,177,0,177,0,177, 0,0,0,177,0,177,
177,177,0,177,0,177,0,177,177,177,177,177,0,177,0, 177,0,177,0,177,0,177,0,0,0,177,0,177,0,177,0,177, 0,177,177,177,177,177,0,177,
177,0,0,177,0,177,0,177,0,0,0,0,0,177,0,177,0,0,0, 177,0,177,0,177,0,0,0,0,0,177,0,177,0,0,0,0,0,0,0, 177,
177,0,177,177,0,177,0,177,0,177,177,177,177,177,0, 177,177,177,177,177,0,177,0,177,177,177,177,177,17 7,177,0,177,177,177,177,177,177,177,177,177,
177,0,0,177,0,177,0,177,0,177,0,0,0,0,0,177,0,0,0, 177,0,177,0,0,0,0,0,0,0,177,0,0,0,0,0,0,0,0,0,177,
177,177,0,177,0,177,0,177,0,177,0,177,177,177,177, 177,0,177,0,177,0,177,177,177,177,177,177,177,0,17 7,177,177,177,177,177,177,177,177,0,177,
177,0,0,177,0,177,0,177,0,177,0,177,0,0,0,177,0,17 7,0,177,0,0,0,177,0,0,0,177,0,177,0,0,0,0,0,177,0, 0,0,177,
177,0,177,177,0,177,0,177,0,177,0,177,0,177,0,177, 0,177,0,177,177,177,0,177,0,177,0,177,0,177,0,177, 177,177,0,177,0,177,177,177,
177,0,177,0,0,177,0,177,0,177,0,177,0,177,0,177,0, 177,0,0,0,0,0,177,0,177,0,0,0,177,0,0,0,177,0,177, 0,0,0,177,
177,0,177,0,177,177,0,177,0,177,0,177,0,177,0,177, 177,177,177,177,177,177,177,177,177,177,177,177,17 7,177,177,177,0,177,0,177,177,177,177,177,
177,0,0,0,177,177,0,0,0,177,0,0,0,177,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,177,0,0,0,0, 4,177,
177,177,177,177,177,177,177,177,177,177,177,177,17 7,177,177,177,177,177,177,177,177,177,177,177,177, 177,177,177,177,177,177,177,177,177,177,177,177,17 7,177,177};
int r = 1, c = 1;
void print(void);
void move(void);
int main()
{
int yo=1;
for (int i = 0; i < size + 1; i++) {
arraybox[i][0] =177;
arraybox[i][size-1] = 177;
arraybox[0][i] = 177;
arraybox[size-1][i] = 177;
}
print();
cout << "\nProccessing\n";
for (int y = 0; y < 50; y++) {
Sleep(10);
cout << '.';
}
move();
cout << endl << "Steps: " << stepInt << endl;
cin>>yo;
return 0;
}
void print()
{
for (int l = 0; l < size; l++) {
cout << endl;
for(int g = 0; g < size; g++)
cout<<static_cast<char>(arraybox[ l ] [g]);
}
}
void move() // just makes sure you cant run into walls
{
int num, end = 0;
srand(time(0));
while (end != 1) {
num = 1 + rand() % 4;
if ( num == 1 && arraybox[r-1][c] != 177) {
arraybox[r][c] = 27;
r = r - 1;
stepInt += 1;
}
else if ( num == 2 && arraybox[r+1][c] != 177 ) {
arraybox[r][c] = 26;
r = r + 1;
stepInt += 1;
}
else if ( num == 3 && arraybox[r][c-1] != 177 ) {
arraybox[r][c] = 24;
c = c - 1;
stepInt += 1;
}
else if ( num == 4 && arraybox[r][c+1] != 177 ) {
arraybox[r][c] = 25;
c = c + 1;
stepInt += 1;
}
if (r == size-2 && c == size-2) {
end = 1;
cout << endl << endl << endl << endl;
arraybox[r][c] = 4;
print();
}
}
}