Пример #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;
}
Пример #2
0
unsigned short int solve::next_action( wall &maze_memorizer, route &route_memorizer,
                                       unsigned short int position[], unsigned short int &direction ) {
  if ( !route_memorizer.has_potential_map ) {
    map_potentials( maze_memorizer, route_memorizer, position, direction );
  }
  if ( (position[0] == GOAL_I_MIN || position[0] == GOAL_I_MAX) && (position[1] == GOAL_J_MIN || position[1] == GOAL_J_MAX) ) {
    if ( mode == NORMAL ) {
      mode = REVERSE;
      return GO_BACKWARD;
    }
  }
  if ( mode == NORMAL ) {
    route_memorizer.put_a_sign_to_reverse( position, direction );
    return route_memorizer.get_the_direction_to_solve( position, direction );
  }
  else if ( mode == REVERSE ) {
    return route_memorizer.get_the_direction_to_reverse( position, direction );
  }
  return DUMMY;
}