Exemplo n.º 1
0
void
Grammar::process( void )
{
	RuleTable::get()->findPrecedences();

	/// Compute the lambda-nonterminals and the first-sets for every
    /// nonterminal
	findFirstSets();

	// Compute all LR(0) states.  Also record follow-set propagation
	// links so that the follow-set can be computed later
	findStates();

	// Tie up loose ends on the propagation links
	findLinks();

	// Compute the follow set of every reducible configuration
	findFollowSets();

	// Compute the action tables
	findActions();

	// Compress the action tables
	if ( isCompressActions() )
		compressTables();

	// Generate a report of the parser generated.  (the "y.output" file) */
	if ( ! isQuiet() )
		reportOutput();

	// Generate the source code for the parser
	outputFiles();
}
Exemplo n.º 2
0
AIAction * AIHints::findAbilityRecursive(AIHint * hint, ManaCost * potentialMana)
{
        RankingContainer ranking = findActions(hint);

        AIAction * a = NULL;
        if (ranking.size())
        {
            a = NEW AIAction(ranking.begin()->first);
        }

        string s = constraintsNotFulfilled(a, hint, potentialMana);
        if (hint->mCombatAttackTip.size() || hint->castOrder.size())
            return NULL;
        if (s.size())
        {
            SAFE_DELETE(a);
            AIHint * nextHint = getByCondition(s);
            DebugTrace("**I Need " << s << ", this can be provided by " << (nextHint ? nextHint->mAction : "NULL") << "\n\n");
            if (nextHint && nextHint != hint)
                return findAbilityRecursive(nextHint, potentialMana);
            return NULL;
        }

        return a;

}
Exemplo n.º 3
0
ActionPlan Planner::Plan2(){
  ActionPlan result;
  auto curr = preConds;
  auto goal = postConds;

  ActionPtr nullAction = Action::ActionFactory("NULL",{},{},0,0);
  ActionCondition start = {curr, nullAction};

  PriorityQueue<ActionNodePtr> acs;
  auto curr_ac  = std::make_shared<ActionNode>();
  curr_ac->action = nullAction;
  curr_ac->conds = curr;
  curr_ac->cost_so_far = 0;
  curr_ac->parent = nullptr;
  
  acs.put(curr_ac,0);
  bool success = false;
  while(!acs.empty()){
    curr_ac  = acs.get();

    if(!satisfies(curr_ac->conds, goal)){
      for(auto& ac : findActions(actions, curr_ac->conds)){
	bool skip = false;
	auto temp_ac = curr_ac;
	while(temp_ac->action->getName() != nullAction->getName()){
	  temp_ac = temp_ac->parent;
	  if(ac.first == temp_ac->conds){
	    skip=true;
	    break;
	  }
	}
	if(skip)
	  continue;
	auto node = std::make_shared<ActionNode>();
	node->action = ac.second;
	node->conds = ac.first;
	node->cost_so_far = ac.second->getCost()+curr_ac->cost_so_far;
	node->parent = curr_ac;
	acs.put(node,node->cost_so_far);
      }
    }
    else{
      success=true;
      break;
    }
  }
  std::cout <<"PLANNED " << std::boolalpha << success << "\n";
  if(!success)
    return result;
  while(curr_ac != nullptr){
    result.push_back(curr_ac->action);
    //std::cout << curr_ac->action << " ";
    curr_ac = curr_ac->parent;
  }
     
  std::reverse(result.begin(), result.end());
  return result;
}
Exemplo n.º 4
0
void CIwGameActionsManager::addActions(CIwGameActions* actions)
{
#if defined(IW_REMOVE_DUPLICATES)
	CIwGameActions* acts = findActions(actions->getNameHash());
	if (acts != NULL)
	{
		CIwGameError::LogError("Warning: Actions already exists, actions list was replaced - ", actions->getName().c_str());
		removeActions(acts);
	}
#endif

	Actions.push_back(actions);
}
Exemplo n.º 5
0
CIwGameActions* CIwGameActionsManager::findActions(const char* name)
{
	return findActions(CIwGameString::CalculateHash(name));
}