Ok, here is what I am attempting.
I have a map (2D array) of the inside of a building for part of my project. The 'working' areas of this map are corridors etc. This working area is divided into zones and there are interfaces between each zone. So for example there could be a corridor zone and a room zone with the doorway as the interface. The interfaces also double up as waypoints, I just assigned 2 different names in case I got confused. Here are the classes I have contructed:
As I hope can be determined, a zone has a vector of all it's intefaces (A corridor can have many rooms and other corridors attached to it). The waypoints class has 2 pointers to zones (one zone either side).
void set_w_coordinates(int pos_x, int pos_y, int a);
void setup(int num_squares, zone &a, zone &b);
int number_of_squares, number_of_interfaces;
void setup(int a, int b);
void set_coordinates(int i, int pos_x, int pos_y);
void set_interfaces(waypoints b);
bool IsInZone(int x, int y);
int GetSquareCoordinate(int i);
vector <waypoints> interfaces;
I am trying to implement a search algorithm that, given start and end coordinates, will populate a vector of zones with the correct sequence of zones (assuming only one route is possible) to get from start to finish.
I have begun a function here:
GetZone() returns the zone containing the coordinates given.
FindZoneRoute(int startx, int endx, int starty, int endy)
vector<zone *> zone_route;
for (vector<waypoints>::iterator wi=GetZone(startx,starty).interfaces.begin(),wi != GetZone(startx,starty).interfaces.end(),wi++)
GetZone1() and GetZone2() return the pointer to zone1 or zone2 respectively held in the zone class.
CompareZones() returns true if the zones passed into it are the same. The if(!CompareZones()) is used so that I don't end up going backwards.
Please bear with me if I clearly haven't got a clue or if my code sucks, I don't know if I am in the right forest, yet alone barking up the right tree!
Any help or guidance would be great, I am lost on this. Thanks