For Horse,
you must difine Four variants in this class or in you programx_old,y_old, x_target,y_target
and you board declare as chessBoard[9][10]
in each bhessBoard, you should save the point of current chesstype. so if there is no chess on this cross, it will be Null.For horse,
the vaild move step isabs(x_old - x_target) = 1
&& abs(y_old - y_target) = 2
&& board[x_old][(y_old + y_target)/2] == NULL
||
abs(x_old - x_target) = 2
&& abs(y_old - y_target) = 1
&& board[x_old + x_target)/2][y_old] == NULL
you must difine Four variants in this class or in you programx_old,y_old, x_target,y_target
and you board declare as chessBoard[9][10]
in each bhessBoard, you should save the point of current chesstype. so if there is no chess on this cross, it will be Null.For horse,
the vaild move step isabs(x_old - x_target) = 1
&& abs(y_old - y_target) = 2
&& board[x_old][(y_old + y_target)/2] == NULL
||
abs(x_old - x_target) = 2
&& abs(y_old - y_target) = 1
&& board[x_old + x_target)/2][y_old] == NULL
解决方案 »
- 多线程下如何协调
- IOCP在有客户端连到服务器的时候,怎么检索到有哦几个客户端连接到iocp的呢?
- 创建了一个继承CListView的类~~不知道怎么显示了~~急救啊~~
- 如下
- ocx控件安装程序需要包含哪些文件?
- PPP点对点拨号用什么?
- 菜鸟问题
- 简单的问题,我不知道错在那里!
- dll的问题,我export一个函数,这个函数的名字叫"Add" 可是我用它来找函数入口地址是0可是我用"Add@@YAHHH@Z"来找地址就可以找到!
- 新年新问题:有谁知道在线点播的实现技术??
- 如何保存html文件?
- 在SDI应用类的InitInstance()函数中,为什么构造多个文档模板时,启动系统总是弹出“新建”对话框???
CanGo: 判断一步棋合不合法
.......
返回值: 合法返回TRUE,不合法返回FALSE
******************************************************************/
BOOL CanGo(int manmap[11][12],int man,const POINT &from,const POINT &to)
{
......
switch(ManToType[man])
{
......
case RED_M:
case BLACK_M:
//马走日:
if(!((abs(to.x-from.x)==1&&abs(to.y-from.y)==2)||(abs(to.x-from.x)==2&&abs(to.y-from.y)==1)))return FALSE;
//找马脚:
if (to.x-from.x==2){i=from.x+1;j=from.y;}
else if(from.x-to.x==2){i=from.x-1;j=from.y;}
else if(to.y-from.y==2){i=from.x;j=from.y+1;}
else if(from.y-to.y==2){i=from.x;j=from.y-1;}
//绊马脚:
if(manmap[i][j]!=32)return FALSE;
break;
default:
break;
}
return TRUE;
}