Your assignment is to modify the program so that the aimless walker stumbles around in a 2-dimensional grid, such as the streets of Manhattan. Your program should prompt the user to enter the number of rows and columns in the 2-d grid. Again, have the walker start in the middle of the grid, then have him stumble randomly in 4 directions, and end the simulation when he falls off the end of the grid.
Thats my assignment, and this is what ive done so far, but i keep getting array errors and im not sure what to do. can anyone help?
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void display(char grid[]);
int rowSize;
int colSize;
int curRow=rowSize/2;
int curCol=colSize/2;
void makeNextmove (int curRow , int curCol , int newRow , int newCol)
{
int coin=rand()%4;
if (coin==1)
(newRow=curRow-1,newCol=curCol);
if (coin==2)
(newRow=curRow,newCol=curCol+1);
return;
}
int main(){
char x; cin>>x;
char street;
cout << "Please enter the number of rows: ";
cin >> rowSize;
cout << "Now please enter the number of columns: ";
cin >> colSize;
bool done=false;
while (!done)
{
makeNextmove(curRow,curCol,newRow,newCol);
street[curRow][curCol]= " ";
street[newRow][newCol]= "D";
if (newRow==0||newRow==rowSize||newCol==0||newCol==colSize)
done=true;
curCol=newCol; curRow=newRow;
}