当前位置: 首页>>代码示例>>C++>>正文


C++ ActionSet::add方法代码示例

本文整理汇总了C++中ActionSet::add方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet::add方法的具体用法?C++ ActionSet::add怎么用?C++ ActionSet::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActionSet的用法示例。


在下文中一共展示了ActionSet::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NSRLastDocItem

bb::cascades::VisualNode*
NSRLastDocItemFactory::createItem (bb::cascades::ListView*	list,
				   const QString&		type)
{
	Q_UNUSED (type);

	NSRLastDocsListView *listView = static_cast<NSRLastDocsListView *> (list);
	NSRLastDocItem *item = new NSRLastDocItem ();
	NSRTranslator *translator = item->getTranslator ();

	ActionSet *actionSet = ActionSet::create ();

	ActionItem *shareAction = ActionItem::create().title (trUtf8 ("Share"));
	ActionItem *hideAction = ActionItem::create().title (trUtf8 ("Clear Recent", "Clear recent files"));
	DeleteActionItem *removeAction = DeleteActionItem::create ();

	shareAction->setImageSource (QUrl ("asset:///share.png"));
	hideAction->setImageSource (QUrl ("asset:///list-remove.png"));

#if BBNDK_VERSION_AT_LEAST(10,2,0)
	shareAction->accessibility()->setName (trUtf8 ("Share file with others"));
	hideAction->accessibility()->setName (trUtf8 ("Remove file from the recent list only"));

	translator->addTranslatable ((UIObject *) shareAction->accessibility (),
				     NSRTranslator::NSR_TRANSLATOR_TYPE_A11Y,
				     QString ("NSRLastDocItemFactory"),
				     QString ("Share file with others"));
	translator->addTranslatable ((UIObject *) hideAction->accessibility (),
				     NSRTranslator::NSR_TRANSLATOR_TYPE_A11Y,
				     QString ("NSRLastDocItemFactory"),
				     QString ("Remove file from the recent list only"));
#endif

	bool ok = connect (shareAction, SIGNAL (triggered ()), listView, SLOT (onShareActionTriggered ()));
	Q_UNUSED (ok);
	Q_ASSERT (ok);

	ok = connect (removeAction, SIGNAL (triggered ()), listView, SLOT (onRemoveActionTriggered ()));
	Q_ASSERT (ok);

	ok = connect (hideAction, SIGNAL (triggered ()), listView, SLOT (onHideActionTriggered ()));
	Q_ASSERT (ok);

	actionSet->add (shareAction);
	actionSet->add (hideAction);
	actionSet->add (removeAction);

	item->addActionSet (actionSet);

	translator->addTranslatable ((UIObject *) shareAction,
				     NSRTranslator::NSR_TRANSLATOR_TYPE_ACTION,
				     QString ("NSRLastDocItemFactory"),
				     QString ("Share"));
	translator->addTranslatable ((UIObject *) hideAction,
				     NSRTranslator::NSR_TRANSLATOR_TYPE_ACTION,
				     QString ("NSRLastDocItemFactory"),
				     QString ("Clear Recent"));

	return item;
}
开发者ID:saprykin,项目名称:nsrreader-bb10,代码行数:60,代码来源:nsrlastdocitemfactory.cpp

示例2: calculateRelevantActions

// builds the relevant action set for this search
	ActionSet calculateRelevantActions() 
	{
		// the initial mask is blank
		ActionSet all;

		// let's say that we will always allow workers and supply producers
		all.add(DATA.getWorker());
		all.add(DATA.getSupplyProvider());

		// loop through each nonzero element of the goal
		for (Action a(0); a<DATA.size(); ++a)
		{
			// if we want some of this action
			if (params.goal.get(a) > 0)
			{
				//printf("GOAL HAS: %s\n", DATA[a].getName().c_str());
				
				// add itself to the mask
				all.add(a);

				// if this action costs gas
				if (DATA[a].gasPrice() > 0) 
				{
					// extractors are now relevant
					all.add(DATA.getRefinery());
				}

				// also add all recursive prerequisites of this action
				calculateRecursivePrerequisites(a, all);
			}
		}

		return all;
	}
开发者ID:iarfmoose,项目名称:MooseBot,代码行数:35,代码来源:DFBBStarcraftSearch.hpp

示例3: getAllActions

	ActionSet getAllActions() const
	{
		ActionSet temp;

		for (int i=0; i<size(); ++i)
		{
			temp.add(i);
		}

		return temp;
	}
开发者ID:SvenFlorian,项目名称:BOB,代码行数:11,代码来源:StarcraftData.hpp

示例4: switch

ActionSet* Bb10Ui::generateActionSetForBuffer(BufferId bufId)
{
    //const Network* net = Client::network(m_networkInfo.networkId);
    
    ActionSet* actions = ActionSet::create();
    BufferInfo::Type itemType = Client::networkModel()->bufferType(bufId);
    switch (itemType) {
    case BufferInfo::StatusBuffer:
    {
        ActionItem* listChannels = ActionItem::create().title("List Channels");
        connect(listChannels, SIGNAL(triggered()), this, SLOT(listChannels()));
        actions->add(listChannels);
        break;
    }
    case BufferInfo::ChannelBuffer:
    {
        ActionItem* join = ActionItem::create().title("Join");
        connect(join, SIGNAL(triggered()), this, SLOT(joinChannel()));
        actions->add(join);
        ActionItem* part = ActionItem::create().title("Part");
        connect(part, SIGNAL(triggered()), this, SLOT(partChannel()));
        actions->add(part);
        ActionItem* del = ActionItem::create().title("Delete");
        connect(del, SIGNAL(triggered()), this, SLOT(deleteBuffer()));
        actions->add(del);
        break;
    }
    case BufferInfo::QueryBuffer:
    {
        ActionItem* del = ActionItem::create().title("Delete");
        connect(del, SIGNAL(triggered()), this, SLOT(deleteBuffer()));
        actions->add(del);
        break;
    }
    default:
        delete actions;
        return 0;
    }
    return actions->count() ? actions : 0;
}
开发者ID:andy-h-chen,项目名称:quassel,代码行数:40,代码来源:bb10ui.cpp

示例5: getAllLegalActions

void GameState::getAllLegalActions(ActionSet & actions) const
{
    const std::vector<ActionType> & allActions = ActionTypes::GetAllActionTypes(getRace());
	for (ActionID i(0); i<allActions.size(); ++i)
	{
        const ActionType & action = allActions[i];

        if (isLegal(action))
        {
            actions.add(action);
        }
    }   
}
开发者ID:edran,项目名称:ualbertabot,代码行数:13,代码来源:GameState.cpp

示例6: generateLegalActions

void DFBB_BuildOrderStackSearch::generateLegalActions(const GameState & state, ActionSet & legalActions)
{
    legalActions.clear();
    DFBB_BuildOrderSearchGoal & goal = _params.goal;
    const ActionType & worker = ActionTypes::GetWorker(state.getRace());
    
    // add all legal relevant actions that are in the goal
    for (size_t a(0); a < _params.relevantActions.size(); ++a)
    {
        const ActionType & actionType = _params.relevantActions[a];

        if (state.isLegal(actionType))
        {
            // if there's none of this action in the goal it's not legal
            if (!goal.getGoal(actionType) && !goal.getGoalMax(actionType))
            {
                continue;
            }

            // if we alread have more than the goal it's not legal
            if (goal.getGoal(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoal(actionType)))
            {
                continue;
            }

            // if we already have more than the goal max it's not legal
            if (goal.getGoalMax(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoalMax(actionType)))
            {
                continue;
            }
            
            legalActions.add(_params.relevantActions[a]);
        }
    }

    // don't make anything until we have 8 workers
    if (state.getUnitData().getNumTotal(worker) < 8)
    {
        legalActions.clear();
        legalActions.add(worker);
        return;
    }

    // if we enabled the supply bounding flag
    if (_params.useSupplyBounding)
    {
        UnitCountType supplySurplus = state.getUnitData().getMaxSupply() + state.getUnitData().getSupplyInProgress() - state.getUnitData().getCurrentSupply();
        UnitCountType threshold = (UnitCountType)(ActionTypes::GetSupplyProvider(state.getRace()).supplyProvided() * _params.supplyBoundingThreshold);

        if (supplySurplus >= threshold)
        {
            legalActions.remove(ActionTypes::GetSupplyProvider(state.getRace()));
        }
    }
    
    // if we enabled the always make workers flag, and workers are legal
    if (_params.useAlwaysMakeWorkers && legalActions.contains(worker))
    {
        bool actionLegalBeforeWorker = false;
        ActionSet legalEqualWorker;
        FrameCountType workerReady = state.whenCanPerform(worker);

        for (size_t a(0); a < legalActions.size(); ++a)
        {
            const ActionType & actionType = legalActions[a];
            const FrameCountType whenCanPerformAction = state.whenCanPerform(actionType);
            if (whenCanPerformAction < workerReady)
            {
                actionLegalBeforeWorker = true;
                break;
            }

            if ((whenCanPerformAction == workerReady) && (actionType.mineralPrice() == worker.mineralPrice()))
            {
                legalEqualWorker.add(actionType);
            }
        }

        if (actionLegalBeforeWorker)
        {
            legalActions.remove(worker);
        }
        else
        {
            legalActions = legalEqualWorker;
        }
    }
}
开发者ID:adamjford,项目名称:ualbertabot,代码行数:88,代码来源:DFBB_BuildOrderStackSearch.cpp

示例7: calculatePrerequisites

	// returns an ActionSet of prerequisites for a given action
	ActionSet calculatePrerequisites(StarcraftAction & action)
	{
		ActionSet pre;

		if (DEBUG_StarcraftData) 
		{
			printf("DEBUG: Hello\n");
			printf("DEBUG: %d  \t%s \t%s\n", getAction(action), action.getName().c_str(), actions[getAction(action)].getName().c_str());
		}

		// if it's a UnitType
		if (action.getType() == StarcraftAction::UnitType)
		{
			std::map<BWAPI::UnitType, int> requiredUnits = action.getUnitType().requiredUnits();
			BWAPI::UnitType actionType = action.getUnitType();

			// if it's a protoss building that isn't a Nexus or Assimilator, we need a pylon (indirectly)
			if (actionType.getRace() == BWAPI::Races::Protoss && actionType.isBuilding() && !actionType.isResourceDepot() && 
				!(actionType == BWAPI::UnitTypes::Protoss_Pylon) && !(actionType == BWAPI::UnitTypes::Protoss_Assimilator))
			{
				pre.add(getAction(BWAPI::UnitTypes::Protoss_Pylon));
			}

			// for each of the required UnitTypes
			for (std::map<BWAPI::UnitType, int>::iterator unitIt = requiredUnits.begin(); unitIt != requiredUnits.end(); unitIt++)
			{
				if (DEBUG_StarcraftData) printf("\tPRE: %s\n", unitIt->first.getName().c_str());
	
				BWAPI::UnitType type = unitIt->first;

				// add the action to the ActionSet if it is not a larva
				if (type != BWAPI::UnitTypes::Zerg_Larva)
				{
					//printf("\t\tAdding %s\n", type.getName().c_str());
					pre.add(getAction(type));
				}
			}

			// if there is a TechType required
			if (action.getUnitType().requiredTech() != BWAPI::TechTypes::None)
			{
				if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getUnitType().requiredTech().getName().c_str());

				// add it to the ActionSet
				pre.add(getAction(action.getUnitType().requiredTech()));
			}
		}

		// if it's a TechType
		if (action.getType() == StarcraftAction::TechType)
		{
			if (action.getTechType().whatResearches() != BWAPI::UnitTypes::None)
			{
				if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getTechType().whatResearches().getName().c_str());

				// add what researches it
				pre.add(getAction(action.getTechType().whatResearches()));
			}
		}

		// if it's an UpgradeType
		if (action.getType() == StarcraftAction::UpgradeType)
		{
			if (action.getUpgradeType().whatUpgrades() != BWAPI::UnitTypes::None)
			{
				if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getUpgradeType().whatUpgrades().getName().c_str());

				// add what upgrades it
				pre.add(getAction(action.getUpgradeType().whatUpgrades()));
			}
		}

		//printf("Finish Prerequisites\n");
		return pre;
	}
开发者ID:SvenFlorian,项目名称:BOB,代码行数:76,代码来源:StarcraftData.hpp

示例8: DFBB


//.........这里部分代码省略.........

		// only use relevant actions
		legalActions = legalActions & relevantActions;
		
		// if we enabled the supply bounding flag
		if (params.useSupplyBounding)
		{
			// if we are more than 2 supply providers in the lead 
			if ((s.getMaxSupply() - s.getCurrentSupply()) >= params.supplyBoundingThreshold*DATA[DATA.getSupplyProvider()].supplyProvided())
			{
				// make supply providers illegal
				legalActions.subtract(DATA.getSupplyProvider());
			}
		}
		
		// if we enabled the always make workers flag, and workers are legal
		if (params.useAlwaysMakeWorkers && !params.goal[DATA.getWorker()] && legalActions[DATA.getWorker()])
		{
			ActionSet tempLegal(legalActions);
			ActionSet legalBeforeWorker;
			
			// compute when the next worker will be trainable
			int workerReady = s.resourcesReady(DATA.getWorker());
			
			// for each other legal action
			while (!tempLegal.isEmpty())
			{
				Action nextAction = tempLegal.popAction();
				
				// if the action will be ready before the next worker
				if (s.resourcesReady(nextAction) <= workerReady)
				{
					// it's legal
					legalBeforeWorker.add(nextAction);
				}
			}
			
			// update the legal actions
			legalActions = legalBeforeWorker;
		}
		
		// if we enabled the use worker cutoff flag and we're above the cutoff
		if (params.useWorkerCutoff && s.getCurrentFrame() > (params.workerCutoff * upperBound))
		{
			// workers are no longer legal
			legalActions.subtract(DATA.getWorker());

			// if we have enough supply for the remaining goal
			if (s.hasEnoughSupplyForGoal(params.goal))
			{
				// make supply providers illegal
				legalActions.subtract(DATA.getSupplyProvider());
			}
		}	

		// if we have children, update the counter
		if (!legalActions.isEmpty())
		{
			numGenerations += 1;
			numChildren += legalActions.numActions();
		}
		
		// load the save state if we are using it
		if (params.useSaveState && !finishedLoadingSaveState)
		{
			// if we are under the saved depth, load accordingly
开发者ID:iarfmoose,项目名称:MooseBot,代码行数:67,代码来源:DFBBStarcraftSearch.hpp


注:本文中的ActionSet::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。