接上面中国象棋代码:
if( check_turn == 12) //相的走法规范
{ if((x == check_x &&y == check_y))
{temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500)
}
else if( x >= 15 &&(abs(y - check_y) == 8 &&abs(x - check_x) == 4))
{if((x == 22 &&(y == 11 || y == 27))||(x == 18 &&
( y == 3 || y == 19 || y == 35)) ||(x == 14 &&(y == 11|| y ==27)))
{ if( map[(x+check_x)/2][(y+check_y)/2] == '+') check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else {printf("棋子卡住,不可执行")Sleep(500)} }
else {printf("不合法的下法\n")Sleep(500)}
}
else {printf("不合法的下法\n")Sleep(500)}
}
if( check_turn == 13) //士的走法规范
{ if((x == check_x &&y == check_y))
{temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( abs(x - check_x)== 2 &&abs( y - check_y) == 4 &&((x==22 &&(y == 15
|| y == 23)) || ( x == 20 &&y == 19) || ( x == 18 &&( y == 15 || y == 23)))) {check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else { printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 14) //将的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( ((abs(x - check_x)== 2 &&abs( y - check_y) == 0 )|| (abs(x - check_x)== 0
&&abs( y - check_y) == 4)) &&x >= 18 &&x <= 22 &&y >= 15 &&y <= 23 )
{ check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else { printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 15) //炮的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( y == check_y )
{ int check_pao = 0
if( x >check_x)
{ for(j = check_x + 2j<= x j = j+ 2)
{ if(map[j][y] == '+' ) else check_pao++}
if(check_pao == 1&&temp == '+') // 直线行走但不可吃棋子 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
else { for(j = check_x - 2j>= xj = j - 2)
{ if(map[j][y] == '+' ) else { check_pao++} }
if(check_pao == 1&&temp == '+') //直线行走但不可吃棋子 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
else if( x == check_x )
{ int check_pao = 0
if( y >check_y)
{ for(j = check_y + 4j<= y j = j+4)
{ if(map[x][j] == '+' ) else check_pao++}
if(check_pao == 1&&temp == '+') //直线行走但不可吃棋子 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
else {for(j = check_y - 4j>= yj = j - 4)
{if(map[x][j] == '+' ) else check_pao++}
if(check_pao == 1&&temp == '+') //直线行走但不可吃棋子 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
else { printf("不合法的下法\n")Sleep(500)}
}
if( check_turn == 16) //卒的走法规范
{ if ( x >= 14)
{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合") Sleep(500) }
else if( x == check_x - 2 &&y == check_y) check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)}
}
else{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1 turn = 'O' turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if((x - check_x == 0 &&abs(y-check_y) ==4) ||( x - check_x == -2
&&abs(y-check_y) == 0)) check_main1(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
}
else { if( check_turn == 20) //车的走法规范 (帅方)
{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1turn = 'O'turn1 = 'N' num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( y == check_y )
{ if( x >check_x)
{ for(j = check_x + 2j <xj = j + 2)
{ if(map[j][y] == '+')else {printf("不合法的下法\n")Sleep(500)break} }
if( j >= x) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
}
if( x <check_x)
{ for(j = check_x - 2j >xj = j - 2)
{ if(map[j][y] == '+')else { printf("不合法的下法\n")Sleep(500)break} }
if( j <= x) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
}
}
else if( x == check_x )
{ if( y >check_y)
{ for(j = check_y + 4j <yj = j + 4)
{ if(map[x][j] == '+')else { printf("不合法的下法\n")Sleep(500)break} }
if( j >= y) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
}
if( y <check_y)
{ for(j = check_y - 4j >yj = j - 4)
{ if(map[x][j] == '+')else { printf("不合法的下法\n")Sleep(500)break} }
if( j <= y) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
}
}
else { printf("不合法的下法\n")Sleep(500)}
}
if( check_turn == 21) //马的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500)}
else if( (abs( x - check_x) == 2&&abs( y - check_y) == 8)&&
map[check_x][(y+check_y)/2] =='+')
{ check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else if( (abs( x - check_x) == 4&&abs( y - check_y) == 4)&&
map[(x + check_x)/2][check_y] == '+' )
{ check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else { printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 22) //相的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500)}
else if( x <= 12 &&(abs(y - check_y) == 8 &&abs(x - check_x) == 4))
{ if((x == 4 &&(y == 11 || y == 27))||(x == 8 &&( y == 3 || y == 19 || y == 35))
||(x == 12 &&(y == 11|| y ==27)))
{ if( map[(x+check_x)/2][(y+check_y)/2] == '+') check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("棋子卡住,不可执行")Sleep(500)} }
else {printf("不合法的下法\n")Sleep(500)}
}
else { printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 23) //士的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( abs(x - check_x)== 2 &&abs( y - check_y) == 4 &&((x==4 &&
(y == 15 || y == 23)) || ( x == 6 &&y == 19) || ( x == 8 &&( y == 15 || y == 23))))
{ check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else { printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 24) //将的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( ((abs(x - check_x)== 2 &&abs( y - check_y) == 0 )|| (abs(x - check_x)== 0 &&abs( y - check_y) == 4)) &&x >= 4 &&x <= 8 &&y >= 15 &&y <= 23 )
{ check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)}
else {printf("不合法的下法\n")Sleep(500)} }
if( check_turn == 25) //炮的走法规范
{ if((x == check_x &&y == check_y))
{ temp = turn temp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if( y == check_y )
{ int check_pao = 0
if( x >check_x)
{ for(j = check_x + 2j<= x j = j+ 2)
{ if(map[j][y] == '+' ) else check_pao++}
if(check_pao == 1&&temp == '+') //直线行走但不可吃棋子 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
else { for(j = check_x - 2j>= xj = j - 2)
{ if(map[j][y] == '+' ) else { check_pao++} }
if(check_pao == 1&&temp== '+') //直线行走但不可吃棋子 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
else if( x == check_x )
{ int check_pao = 0
if( y >check_y)
{ for(j = check_y + 4j<= y j = j+4)
{ if(map[x][j] == '+' ) else check_pao++}
if(check_pao == 1&&temp == '+') //直线行走但不可吃棋 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2 &&temp != '+') //跳跃吃棋 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
else { for(j = check_y - 4 j>= yj = j - 4)
{ if(map[x][j] == '+' ) else check_pao++}
if(check_pao ==1&&temp == '+') //直线行走但不可吃棋子 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else if( check_pao == 2&&temp != '+') //跳跃吃棋 check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
else { printf("不合法的下法\n")Sleep(500)}
}
if( check_turn == 26) //卒的走法规范
{ if( x <= 12)
{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500)}
else if( x == check_x + 2 &&y == check_y) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
else{ if((x == check_x &&y == check_y))
{ temp = turntemp1 = turn1turn = 'O'turn1 = 'N'num--
printf("三思而后行\n")printf("还是你的回合")Sleep(500) }
else if((x - check_x == 0 &&abs(y-check_y) ==4) ||( x - check_x == 2
&&abs(y-check_y) == 0)) check_main2(&temp,&temp1,&turn,&turn1,&num,&if_return,map)
else { printf("不合法的下法\n")Sleep(500)} }
}
}
}
}
system("cls")
if( if_return) return
for(i = 0i <27i++)puts(map[i])
}
Sleep(5000)
}
int main( )
{ while(1)
{ xiangqi( )
printf("\n 重来,请按键.\n")
getch( )
}
return 0
}
现在最厉害的单机版中国象棋软件如下:象棋奇兵:战胜过特级大师
xiexie master:业余高手
象棋世家:业余高手
以上三种软件均可以在网上下载到,他们的水平和你给他们设置的思考时间有关,电脑思考时间越长,它越厉害。最快可以设置成1秒钟1步,水平相当于业余中级水平吧。
现在的中国象棋软件很厉害,赢过吕钦和许银川,逼和过于幼华。
另外还有一个叫“纵马奔流”的软件,据说很厉害,但是现在网上找不到。
单机版中国象棋大师下载http://www.anwang.cn/soft/6/34/2006/20060315602.html
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)