Originally Posted by
tabstop
You need to randomly generate (x,y) coordinates, and then change the value in your grid at that spot to some otherwise-impossible number (bigger than your limit, or smaller than your minimum).
Hi again,
With a help of a mate I have sort out the matrix:
Code:
//My Variables
int matrix[12][12];
char dnum[3];
int i, i2,m;
//function to generate the matrix
void generatematrix(void){
srand(time(NULL));//Determine Rand Base Number
for(i=0;i<12;i++){
for(i2=0;i2<12;i2++)
matrix[i][i2] = (rand() % 250);
}
addspaces(25);
}
//function to display the matrix
void displaymatrix(void){
clrscr();
for(i=0;i<12;i++){
for(i2=0;i2<12;i2++){
if(matrix[i][i2] == 250){
printf("[ ]");
continue;
}
setmovecol(i,i2);
itoa(matrix[i][i2],dnum,10);
printf("[%03s]",dnum);
settextbackgroundcolour(black,0);
}
printf("\n");
}
//function to add blank spaces
void addspaces(int max){
int r1,r2;
for(i=0;i<max;i++){
r1 = (rand() % 10);
r2 = (rand() % 10);
matrix[r1][r2] = 250;
}
}
Now can you please guide me. You said before there are 4 possible starting cells. I would like to point to all of them and choose the one that does no contain a blank space and after how do i move to the next cell to sort out the maze?
Thanks!