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


C++ state::getBoard方法代码示例

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


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

示例1:

/**
FUNCTION: overload == operator
DESCRIPTION: Overloads the == operator so that it can be used to test wheather or not 'this' state is equal to otherState.
RETURN bool - True if in fact 'this' state is equal to otherState
*/
bool state::operator== (const state& otherState) const{
	if(otherState.boardMemoryAllocated == false) return false;
	if(this->getBoard()[0][0] != otherState.getBoard()[0][0])return false;
	if(this->getBoard()[0][1] != otherState.getBoard()[0][1])return false;
	if(this->getBoard()[0][2] != otherState.getBoard()[0][2])return false;
	if(this->getBoard()[1][0] != otherState.getBoard()[1][0])return false;
	if(this->getBoard()[1][1] != otherState.getBoard()[1][1])return false;
	if(this->getBoard()[1][2] != otherState.getBoard()[1][2])return false;
	if(this->getBoard()[2][0] != otherState.getBoard()[2][0])return false;
	if(this->getBoard()[2][1] != otherState.getBoard()[2][1])return false;
	if(this->getBoard()[2][2] != otherState.getBoard()[2][2])return false;
	return true;
}
开发者ID:rsanders16,项目名称:COMS-229--Project-3,代码行数:18,代码来源:8-puzzle.cpp

示例2: state

	/**
	COPY CONSTRUCTOR:  state(const state& obj)
	DESCRIPTION:  Deep copyes obj to this object
	PARAMS:
	obj - The obj that this object is about to become.
	*/
state::state(const state& obj){
	this->g = obj.g;
	this->parent = obj.parent;
	if(obj.boardMemoryAllocated == true){
		this->board = new int*[NUM_ROWS_ON_BOARD];
		for(int i = 0 ; i < NUM_ROWS_ON_BOARD; i++)
		{
			this->board[i] = new int[NUM_COLS_ON_BOARD];
		}
		this->board[0][0] = obj.getBoard()[0][0];
		this->board[0][1] = obj.getBoard()[0][1];
		this->board[0][2] = obj.getBoard()[0][2];
		this->board[1][0] = obj.getBoard()[1][0];
		this->board[1][1] = obj.getBoard()[1][1];
		this->board[1][2] = obj.getBoard()[1][2];
		this->board[2][0] = obj.getBoard()[2][0];
		this->board[2][1] = obj.getBoard()[2][1];
		this->board[2][2] = obj.getBoard()[2][2];
		this->move = obj.move;
	}
}
开发者ID:rsanders16,项目名称:COMS-229--Project-3,代码行数:27,代码来源:8-puzzle.cpp


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