Chelp261 0 Newbie Poster

I have a program which is as follows:

We'll extend the Search and Rescue Simulator. You will implement a class to represent the location of a person, and add searchers to the simulation. A Person class that will be used to represent both the missing person and the searchers, details are described below. The figure below shows the set up with an expanded grid and the Hiker (H) starting in the middle of the grid. After some number of hours, the hiker is reported missing. During that time, the hiker has probably moved from the original location. The Person class models the hiker's movements using the random_move function. The searchers (S) are then added to the grid, starting from position [0][0]. The searchers will be instances of the same Person class as the lost hiker, so they will using the same random_move function. The search can be coded as a while loop. At each time step (one hour), both the hiker and the searchers will move one cell. The program will then determine whether the missing person has been found (i.e., one of the searchers is in the same grid cell as the hiker). A variable named num_hours will be used to count the number of hours that have passed (i.e., the number of times the loop is executed). The next two figures show a possible state of the search after one time step, and a possible state when the hiker is found.

This is the assignment I've been given and thus far I have for the random movement of the hiker to be:

#include <cstdlib>
using namespace std;

// original position is hiker{NS,EW}, new position placed in new{NS,EW}
// one random variable consumed.
void random_move( int hikerNS, int hikerEW, int gridsize, int& newNS, int& newEW )
{
	const int MAX_MOVEMENTS(9);
	// ns and es remember where each valid move goes to 
	int ns[MAX_MOVEMENTS], ew[MAX_MOVEMENTS];
	// counts the valid moves
	int moves = 0;
	for( int v=hikerNS-1; v<=hikerNS+1; v++ ) {
		for( int h=hikerEW-1; h<=hikerEW+1; h++ ) {
			if( h>=0 && h<gridsize && v>=0 && v<gridsize ) {
				// is valid, remember its coords...
				ns[moves] = v;
				ew[moves] = h;
				// goto the next move
				moves++;
			}
		}
	}

	// pick one randomly
	int m = rand() % moves;
	// update position
	newNS = ns[m];
	newEW = ew[m];
	// debug
	//cout << hikerNS << "," << hikerEW << "->" << newNS << "," << newEW << " " ;
}

However, after here I'm stuck and don't know what to do can anyone help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.