예제 #1
0
파일: search.c 프로젝트: aleix13/PDDL
int expand_first_node( int h )

{

  static Bool fc = TRUE;
  static State S_;

  int h_, i, g;

  if ( fc ) {
    make_state( &S_, gnum_ft_conn );
    S_.max_F = gnum_ft_conn;
    fc = FALSE;
  }

  h_ = get_1P_and_H( &(lehc_current_start->S), &lcurrent_goals );
    
  if ( h_ == INFINITY ) {
    lehc_current_start = lehc_current_start->next;
    return h_;
  }

  if ( lehc_current_start->new_goal != -1 &&
       new_goal_gets_deleted( lehc_current_start ) ) {
    lehc_current_start = lehc_current_start->next;
    return INFINITY;
  }

  if ( h_ < h ) {
    return h_;
  }

  for ( i = 0; i < gnum_H; i++ ) {
    g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] );
    add_to_ehc_space( &S_, gH[i], lehc_current_start, g );
  }
    
  lehc_current_start = lehc_current_start->next;

  return h_;

}
예제 #2
0
/* breath first search */
int expand_first_node( int h ) {

	static Bool fc = TRUE;
	static State S_;

	int h_, i, g;

	if ( fc ) {
		make_state( &S_, gnum_ft_conn );
		S_.max_F = gnum_ft_conn;
		fc = FALSE;
	}

	h_ = get_1P_and_H( &(lehc_current_start->S), &lcurrent_goals );

	if ( h_ == INFINITY ) {
		lehc_current_start = lehc_current_start->next;
		return h_;
	}

	if ( lehc_current_start->new_goal != -1 && new_goal_gets_deleted( lehc_current_start ) ) {
			lehc_current_start = lehc_current_start->next;
			return INFINITY;
	}

	if ( h_ < h ) {
		return h_;
	}

	for ( i = 0; i < gnum_H; i++ ) {
		/*JC: dismiss invalid actions*/
		int k;
		Bool found = FALSE;
		for(k = 0; k < gnum_IV; k++){
			if(same_state(&gInvActs[k].state, &(lehc_current_start->S)) && gH[i] == gInvActs[k].act){
				found = TRUE;
				break;
			}
		}
		if(found)
			continue;
		
		if(is_D_action(gop_conn[gH[i]].action->name)) continue;

		g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] );
		add_to_ehc_space( &S_, gH[i], lehc_current_start, g );
	}


	for ( i = 0; i < gnum_H; i++ ) {
		/*JC: dismiss invalid actions*/
		int k;
		Bool found = FALSE;
		for(k = 0; k < gnum_IV; k++){
			if(same_state(&gInvActs[k].state, &(lehc_current_start->S)) && gH[i] == gInvActs[k].act){
				found = TRUE;
				break;
			}
		}
		if(found)
			continue;
		
		if(!is_D_action(gop_conn[gH[i]].action->name)) continue;

		g = result_to_dest( &S_, &(lehc_current_start->S), gH[i] );
		add_to_ehc_space( &S_, gH[i], lehc_current_start, g );
	}
	lehc_current_start = lehc_current_start->next;
	return h_;
}