Ejemplo n.º 1
0
unsigned short int search::next_action( wall &maze_memorizer, route &route_memorizer,
                                        unsigned short int position[], unsigned short int direction ) {
  unsigned short int next_action;
  if ( mode == REVERSE && virtual_route.get_the_direction_to_solve( position, direction ) == DUMMY ) {
    mode = NORMAL;
    virtual_route.has_potential_map = 0;
    virtual_route.reset_the_map_to_solve();
  }
  if ( mode == NORMAL ) {
    next_action = _normal.next_action( maze_memorizer, route_memorizer, position, direction, virtual_walls );
    if ( _normal.is_done ) {
      mode = REVERSE;
      _normal.is_done = 0;
    }
  }
  if ( mode == REVERSE ) {
    if ( !virtual_route.has_potential_map ) {
      mode = NORMAL;
      map_potentials( maze_memorizer, route_memorizer, position, direction );
      mode = REVERSE;
    }
    next_action = virtual_route.get_the_direction_to_solve( position, direction );
  }
  return next_action;
}