#ifndef HEADER_BESTROUTE
#define HEADER_BESTROUTE

/**
 * @file 
 * File containing the interface of bestroute module
 */
#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include "define.h"
#include "object.h"

/* Start interface of bestroute module */

/**
  * 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 ).
  * @return Best route value (unsigned int).
*/
unsigned int bestroute( unsigned int *doorsRow, /**< Number of row of the doors*/
                        unsigned int *doorsCol, /**< Number of column of the
                                                 doors*/      
                        unsigned int numOfDoor, /**< Number of doors*/  
                        unsigned int *doorId    /**< Nearest door to the start
                                                 point*/
                      );


/** Check the input data given to bestroute function.
  * @return true if all controls are ok.
*/
bool bestroute_check_in_data( const unsigned int *doorsRow,
                              const unsigned int *doorsCol,
                                    unsigned int numOfDoor
                            );

/** Implements a circular serach in a estabilished order
  * ( LEFT - DOWN - RIGHT - UP ) looking for available cells,
  * saving the results in given vectors.
  * @return the number of connected nodes (or vectors length)
*/
unsigned int schema_round_search( unsigned int *vectRow,
                                  unsigned int *vectCol,
                                  long int  *vectParent
                                );

/** Starting from a point (doorIndex), follow the 'route'
  * to the main parent.
  * @return the number of steps (or route length)
*/
unsigned int reverse_route_length( unsigned int *vectRow,
                                   unsigned int *vectCol,
                                   long int  *vectParent,
                                   long int doorIndex

                                 );
                                 
/* End interface of bestroute module */

#endif
