obj->A[this->i][this->j]=obj->A[this->i-1][this->j];
obj->A[this->i-1][this->j]=0;
obj->parent=this;
obj->op=2;
obj->i=this->i-1;
obj->j=this->j;
obj->depth=this->depth+1;
for(int m=0;m<3;m++)
for(int n=0;n<3;n++)
if(obj->A[m][n]!=Goal[m][n]) obj->score++;
return obj;
}else
{
//cout<<"空牌不能 Top 移"<<endl;
return NULL;
}
}//end of Top
/* 空牌右移*/
EightNumber * Right()
{
if(this->j<2 && this->op!=-1 )
{
EightNumber * obj=new EightNumber();
for(int m=0;m<3;m++)
for(int n=0;n<3;n++)
obj->A[m][n]=this->A[m][n];
obj->A[this->i][this->j]=obj->A[this->i][this->j+1];
obj->A[this->i][this->j+1]=0;
obj->parent=this;
obj->op=1;
obj->i=this->i;
obj->j=this->j+1;
obj->depth=this->depth+1;
for(int m=0;m<3;m++)
for(int n=0;n<3;n++)
if(obj->A[m][n]!=Goal[m][n]) obj->score++;
return obj;
}else
{
//cout<<"空牌不能右移"<<endl;
return NULL;
}
}
/* 空牌向下移动 */
评论4
最新资源