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


C++ PlayerState::GetY方法代码示例

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


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

示例1: calculatePaths

void CDynamicProgrammingStrategy::calculatePaths() {
    while (!stateQueue.empty()) {
        PlayerState currentState = stateQueue.front();

        for (int xDeviation = -1; xDeviation <= 1; ++xDeviation) {
            for (int yDeviation = -1; yDeviation <= 1; ++yDeviation) {
                PlayerState newState(
                        currentState.GetX() + currentState.GetXVelocity() + xDeviation,
                        currentState.GetY() + currentState.GetYVelocity() + yDeviation,
                        currentState.GetXVelocity() + xDeviation,
                        currentState.GetYVelocity() + yDeviation
                );

                if (newState.GetX() < 0 || newState.GetX() >= map.sizeOnXaxis()
                        || newState.GetY() < 0 || newState.GetY() >= map.sizeOnYaxis()
                        || !map.canPlayerStayOnCell(newState.GetX(), newState.GetY())
                        || map.hasBarrierOnPath(currentState.GetX(), currentState.GetY(),
                                newState.GetX(), newState.GetY())) {
                    continue;
                }

                if (minPath.GetStepCount(newState) == -1 ||
                        minPath.GetStepCount(newState) > minPath.GetStepCount(currentState) + 1) {
                    minPath.SetStepCount(newState, minPath.GetStepCount(currentState) + 1);
                    minPath.SetPreviousState(newState, currentState);
                    stateQueue.push(newState);
                }
            }
        }

        stateQueue.pop();
    }
}
开发者ID:ngc696,项目名称:AI-ABBYY,代码行数:33,代码来源:CDynamicProgrammingStrategy.cpp

示例2: nextMoveForPlayer

EMovementDirection Game::nextMoveForPlayer(int playerID) {
    PlayerState currentPlayer = (*players)[playerID];
    if (currentPlayer.GetX() == finishPoint.first && currentPlayer.GetY() == finishPoint.second) {
        //std::cout << "FINISH" << std::endl;
        return EMovementDirection::FINISH_POSITION;
    } else {
        SNode currentStart(currentPlayer.GetX(), currentPlayer.GetY(), currentPlayer.GetXVelocity(), currentPlayer.GetYVelocity());
        SNode finish(finishPoint.first, finishPoint.second, 0, 0);
        SNode resultNode = aStarStrategyOnYAGSBPL->searchPath(currentStart, finish);
        (*players)[playerID].changePosition(std::make_pair(resultNode.position.first, resultNode.position.second));
        (*players)[playerID].changeVelocityVector(std::make_pair(resultNode.velocityVector.first, resultNode.velocityVector.second));
        return resultNode.direction;
    }
}
开发者ID:adanilyak,项目名称:AI-ABBYY,代码行数:14,代码来源:CGame.cpp

示例3: canIntersectFinishLine

bool CDynamicProgrammingStrategy::canIntersectFinishLine(PlayerState state, int &xDeviation_, int &yDeviation_) const {
	for (int xDeviation = -1; xDeviation <= 1; ++xDeviation) {
		for (int yDeviation = -1; yDeviation <= 1; ++yDeviation) {
			int newX = state.GetX() + state.GetXVelocity() + xDeviation;
			int newY = state.GetY() + state.GetYVelocity() + yDeviation;

			if (newX < 0 || newX >= map.sizeOnXaxis() ||
				newY < 0 || newY >= map.sizeOnYaxis()) {
				continue;
			}

			if (map.intersectFinishLine(state.GetX(), state.GetY(), newX, newY) &&
				!map.hasBarrierOnPath(state.GetX(), state.GetY(), newX, newY))
			{
				xDeviation_ = xDeviation;
				yDeviation_ = yDeviation;
				return true;
			}
		}
	}
	
	return false;
}
开发者ID:ngc696,项目名称:AI-ABBYY,代码行数:23,代码来源:CDynamicProgrammingStrategy.cpp

示例4: make_pair

std::pair<int, int> CDynamicProgrammingStrategy::GetNextPosition() {
    PlayerState nextState = optimalPath.top();
    optimalPath.pop();
    return std::make_pair(nextState.GetX(), nextState.GetY());
}
开发者ID:ngc696,项目名称:AI-ABBYY,代码行数:5,代码来源:CDynamicProgrammingStrategy.cpp


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