Location Matrix::randomAdjacentLocation(Location& location)
{ int row = location.getRow();
int col = location.getCol();
.
.
}
Above ‘location’ represents an occupied point in a two-dimensional matrix. How can I use row, col and rand() to generate a (random) point that is adjacent to ‘location’? If all adjacent points to ‘location’ are occupied, how can I get the function to look further afield, that is, how can I increment row and col non-uniformly? I would be very grateful for all help.
{ int row = location.getRow();
int col = location.getCol();
.
.
}
Above ‘location’ represents an occupied point in a two-dimensional matrix. How can I use row, col and rand() to generate a (random) point that is adjacent to ‘location’? If all adjacent points to ‘location’ are occupied, how can I get the function to look further afield, that is, how can I increment row and col non-uniformly? I would be very grateful for all help.