本文整理汇总了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;
}
示例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;
}
}