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


C++ MoveArray::numMoveTuples方法代码示例

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


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

示例1: getNumMoveTuples

const MoveTuple AlphaBeta::getNumMoveTuples(MoveArray & moves, const TTLookupValue & TTval, const IDType & playerToMove, const size_t & depth) const
{
	// if we are doing opponent modeling, there is just one move to do
	if (_params.usePlayerModel(playerToMove))
	{
		return 1;
	}

	// if there is a transposition table entry for this state
	if (TTval.found())
	{
		// if there was a valid move found with higher depth, just do that one
		const AlphaBetaMove & abMove = getAlphaBetaMove(TTval, playerToMove);
		if ((TTval.entry()->getDepth() >= depth) && abMove.isValid() && (abMove.moveTuple() < moves.numMoveTuples()))
		{
			return 1;
		}
	}

	// otherwise, it's the number of possible moves + number of ordered moves
	return moves.numMoveTuples();
}
开发者ID:welwa,项目名称:ualbertabot,代码行数:22,代码来源:AlphaBeta.cpp

示例2: getMoveTuple

// get desired move tuple for this player's strategy
const MoveTuple Player_Random::getMoveTuple(GameState & state, const MoveArray & moves)
{
	//boost::random::uniform_int_distribution<> dist(0, moves.numMoveTuples() - 1);
		
	return rand() % moves.numMoveTuples();
}
开发者ID:CMPUT350UAlbertabotStrategy,项目名称:Replay-Parser,代码行数:7,代码来源:Player.cpp

示例3: generateOrderedMoves

void AlphaBeta::generateOrderedMoves(GameState & state, MoveArray & moves, const TTLookupValue & TTval, const IDType & playerToMove, const size_t & depth)
{
	// get the array where we will store the moves and clear it
	Array<MoveTuple, Search::Constants::Max_Ordered_Moves> & orderedMoves(_orderedMoves[depth]);
	orderedMoves.clear();

	// if we are using opponent modeling, get the move and then return, we don't want to put any more moves in
	if (_params.usePlayerModel(playerToMove))
	{
		MoveTuple playerModelMove = _params.getPlayer(playerToMove)->getMoveTuple(state, moves);
		orderedMoves.add(playerModelMove);
		return;
	}

	// if there is a transposition table entry for this state
	if (TTval.found())
	{
		// get the abMove we stored for this player
		const AlphaBetaMove & abMove = getAlphaBetaMove(TTval, playerToMove);

		// here we get an incorrect move from the transposition table
		if (abMove.moveTuple() >= moves.numMoveTuples())
		{
			HashType h0 = state.calculateHash(0);
			HashType h1 = state.calculateHash(1);

			MoveArray moves2;
			state.generateMoves(moves2, playerToMove);
			// figure out why
			//fprintf(stderr, "Something very wrong, this tuple (%d) doesn't exist, only (%d) moves\n", (int)abMove.moveTuple(), (int)moves.numMoveTuples());
		}

		_results.ttFoundCheck++;

		// Two checks:
		// 1) Is the move 'valid' ie: was it actually set inside the TT
		// 2) Is it a valid tuple number for this move set? This guards against double
		//    hash collision errors. Even if it is a collision, this is just a move
		//    ordering, so no errors should occur.
		if (abMove.isValid() && (abMove.moveTuple() < moves.numMoveTuples()))
		{
			orderedMoves.add(abMove.moveTuple());
			_results.ttMoveOrders++;
			return;
		}
		else
		{
			_results.ttFoundButNoMove++;
		}
	}

	// if we are using script modeling, insert the script moves we want
	if (_params.useScriptMoveFirst())
	{
		for (size_t s(0); s<_allScripts.size(); s++)
		{
			MoveTuple scriptMove = _allScripts[s]->getMoveTuple(state, moves);

			orderedMoves.addUnique(scriptMove);
		}
	}
}
开发者ID:welwa,项目名称:ualbertabot,代码行数:62,代码来源:AlphaBeta.cpp


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