#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include "define.h"
#include "object.h"
Go to the source code of this file.
Functions | |
unsigned int | bestroute (unsigned int *doorsRow, unsigned int *doorsCol, unsigned int numOfDoor, unsigned int *doorId) |
Function that calculate the best route from the start point and each door of the schema, and selects the shortest of theese. | |
bool | bestroute_check_in_data (const unsigned int *doorsRow, const unsigned int *doorsCol, unsigned int numOfDoor) |
Check the input data given to bestroute function. | |
unsigned int | schema_round_search (unsigned int *vectRow, unsigned int *vectCol, long int *vectParent) |
Implements a circular serach in a estabilished order ( LEFT - DOWN - RIGHT - UP ) looking for available cells, saving the results in given vectors. | |
unsigned int | reverse_route_length (unsigned int *vectRow, unsigned int *vectCol, long int *vectParent, long int doorIndex) |
Starting from a point (doorIndex), follow the 'route' to the main parent. |
Definition in file bestroute.h.
unsigned int bestroute | ( | unsigned int * | doorsRow, | |
unsigned int * | doorsCol, | |||
unsigned int | numOfDoor, | |||
unsigned int * | doorId | |||
) |
Function that calculate the best route from the start point and each door of the schema, and selects the shortest of theese.
It uses an algorithm that analize the boxes iteratively, evalueting each box (step of the route), looking for the cheaper neighbour in a estabilished order ( LEFT - DOWN - RIGHT - UP ).
doorsRow | Number of row of the doors | |
doorsCol | Number of column of the doors | |
numOfDoor | Number of doors | |
doorId | Nearest door to the start point |
Definition at line 9 of file bestroute.c.
References bestroute_check_in_data(), D1, D2, D4, schemaProp::numCol, schemaProp::numRow, reverse_route_length(), schema_round_search(), schemaData, schemaProp::startCol, and schemaProp::startRow.
Referenced by newgame().
bool bestroute_check_in_data | ( | const unsigned int * | doorsRow, | |
const unsigned int * | doorsCol, | |||
unsigned int | numOfDoor | |||
) |
Check the input data given to bestroute function.
Definition at line 91 of file bestroute.c.
References D1, MAXC, MAXR, MINC, MINR, schemaProp::numCol, schemaProp::numRow, schemaData, schemaProp::startCol, and schemaProp::startRow.
Referenced by bestroute().
unsigned int reverse_route_length | ( | unsigned int * | vectRow, | |
unsigned int * | vectCol, | |||
long int * | vectParent, | |||
long int | doorIndex | |||
) |
Starting from a point (doorIndex), follow the 'route' to the main parent.
Definition at line 306 of file bestroute.c.
Referenced by bestroute().
unsigned int schema_round_search | ( | unsigned int * | vectRow, | |
unsigned int * | vectCol, | |||
long int * | vectParent | |||
) |
Implements a circular serach in a estabilished order ( LEFT - DOWN - RIGHT - UP ) looking for available cells, saving the results in given vectors.
Definition at line 194 of file bestroute.c.
References D1, D3, D5, schemaProp::gameMap, isaccessible(), schemaProp::numCol, schemaProp::numRow, and schemaData.
Referenced by bestroute().