//代码之繁杂,没有整理,而且没有整理价值
//记录一下学习行径还是可以的,或许咱都一样也不一定
#include"game.h"
#include<windows.h>
#include<iostream>
#include<conio.h>
char *qizi[]={"帅","士","象","马","车","炮","兵","◇","☆","将","仕","相","馬","車","泡","卒"};
int map[S]={
5,4,3,2,1,2,3,4,5,
0,0,0,0,0,0,0,0,0,
0,6,0,0,0,0,0,6,0,
7,0,7,0,7,0,7,0,7,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
17,0,17,0,17,0,17,0,17,
0,16,0,0,0,0,0,16,0,
0,0,0,0,0,0,0,0,0,
15,14,13,12,11,12,13,14,15,
};
int T_map[S]={};
int px=1,py=5;
int QZ_x=-1;
int QZ_y=-1;
int t=0;
bool luozi=false;
bool x_free=true;
bool H_red=true;
bool red=false; //----------------胜负判断
bool black=false;
bool Y_t=true; //----可以选择棋子
void SetColor(int color)//---------------------------------设置颜色
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hOut, color);
}
void MoveCursor(int x, int y)//-----------------------------设置光标位置
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);///获取输出流句柄
COORD coord;///定义COORD结构体(包含X和Y两个成员)
coord.X = x * 2; ///设置结构体X轴
coord.Y = y; ///设置结构体Y轴
SetConsoleCursorPosition(hOut, coord);///设置光标位置
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };///修改光标宽带和显示
SetConsoleCursorInfo(hOut, &cursor_info);///设置光标不可见◇","☆"
}
void draw()
{
MoveCursor(2, 2);
std::cout<<" 《《 中 国 象 棋 》》 ";
MoveCursor(4, 16);
std::cout<<"光标:x = "<<px<<" ,y = "<<py;
MoveCursor(23, 3);
std::cout<<"游戏指南";
MoveCursor(20, 5);
std::cout<<"W . A . S . D . 移动光标";
MoveCursor(20, 8);
std::cout<<"当光标在棋子上可按空格键拾起";
MoveCursor(20, 10);
std::cout<<"------“ ◇ ”------可移动位置";
MoveCursor(20, 12);
std::cout<<"------“ ☆ ”------可吃掉棋子";
MoveCursor(20, 14);
std::cout<<"-----☆ . F . ☆ --落子-----";
for(int y=0;y<H;++y)
{
MoveCursor(6, y+5);
for(int x=0;x<W;++x)
{
if( x == px && y == py )
std::cout<<"⊙";
else if(T_map[x+y*W] != 0)
std::cout<<qizi[T_map[x+y*W]-1];
else if(map[x+y*W]!=0)
{
if(map[x+y*W]<8)
std::cout<<qizi[map[x+y*W]-1];
else if(map[x+y*W]>8)
std::cout<<qizi[map[x+y*W]-2];
else if(map[x+y*W]==8)
std::cout<<qizi[7];
else if(map[x+y*W]==9)
std::cout<<qizi[8];
}
else if( y == 0 && x == 0 )
std::cout<<"┌";
else if( y == 0 && x == 8 )
std::cout<<"┐";
else if( y == 1 && x == 4 )
std::cout<<"╳";
else if( y == 8 && x == 4 )
std::cout<<"╳";
else if( y == 2 && x == 1 )
std::cout<<"╬";
else if( y == 2 && x == 7 )
std::cout<<"╬";
else if( y == 7 && x == 1 )
std::cout<<"╬";
else if( y == 7 && x == 7 )
std::cout<<"╬";
else if( y == 3 && x == 2 )
std::cout<<"╬";
else if( y == 3 && x == 4 )
std::cout<<"╬";
else if( y == 3 && x == 6 )
std::cout<<"╬";
else if( y == 6 && x == 2 )
std::cout<<"╬";
else if( y == 6 && x == 4 )
std::cout<<"╬";
else if( y == 6 && x == 6 )
std::cout<<"╬";
else if( y == 9 && x == 0 )
std::cout<<"└";
else if( y == 9 && x == 8 )
std::cout<<"┘";
else if( y == 0 && x > 0 && x < 8 )
std::cout<<"┬";
else if( y == 4 && x > 0 && x < 8 )
std::cout<<"┴";
else if( y == 5 && x > 0 && x < 8 )
std::cout<<"┬";
else if( y == 9 && x > 0 && x < 8 )
std::cout<<"┴";
else if( x == 0 && y > 0 && y < 9 )
std::cout<<"├";
else if( x == 8 && y > 0 && y < 9 )
std::cout<<"┤";
else
std::cout<<"┼";
}
std::cout<<std::endl;
}
}
void run()
{
int get=_getch();
if( get == 'W' || get == 'w' )
{if( py - 1 >= 0 )py--;}
else if( get == 'S' || get == 's' )
{if( py + 1 < 10 )py++;}
else if( get == 'A' || get == 'a' )
{if( px - 1 >= 0 )px--;}
else if( get == 'D' || get == 'd' )
{if( px + 1 < 9 )px++;}
else if( get == ' ' ) //----------------------------------------------选择动子
{
if( H_red == true && Y_t && map[px+py*W] > 0 && map[px+py*W] < 8)
{
QZ_x=px;
QZ_y=py;
x_free=false;
H_red = false;
luozi=true;
Y_t=false;
}
if( H_red == false && Y_t && map[px+py*W] > 9 && map[px+py*W] < 18)
{
QZ_x=px;
QZ_y=py;
x_free=false;
H_red = true;
luozi=true;
Y_t=false;
}
if(!Y_t)//----取消选择----
{
Y_t=true;
H_red = !H_red;
for(int i=0;i<S;++i)//------------------ memset可以
{
T_map[i]=0;
}
}
}
if(get == 'F' || get == 'f' )
{
if(luozi && (T_map[px+py*W]==8 || T_map[px+py*W]==9 ))
{
map[px+py*W]=map[QZ_x+QZ_y*W];
map[QZ_x+QZ_y*W]=0;
luozi=false;
H_red =!H_red;
Y_t=true;
for(int i=0;i<S;++i)//------------------ memset可以
{
T_map[i]=0;
}
}
}
int x=QZ_x,y=QZ_y;
int x1=x,x2=x,y1=y,y2=y;
int pao1=9,pao2=0,pao3=10,pao4=0;
switch(map[x+y*W])
{ // ----帅------------------------
case 1:if((map[x-1+y*W]==0 || map[x-1+y*W]>9) && x-1> 2)
{
if(map[x-1+y*W]==0)T_map[x-1+y*W]=8;
if(map[x-1+y*W]>9)T_map[x-1+y*W]=9;
}
if((map[x+1+y*W]==0 || map[x+1+y*W]>9) && x+1< 6)
{
if(map[x+1+y*W]==0)T_map[x+1+y*W]=8;
if(map[x+1+y*W]>9)T_map[x+1+y*W]=9;
}
if((map[x+y*W-W] == 0 || map[x+y*W-W]>9) && y-1>= 0)
{
if(map[x+y*W-W] == 0)T_map[x+y*W-W]=8;
if(map[x+y*W-W]>9)T_map[x+y*W-W];
}
if((map[x+y*W+W]==0 || map[x+y*W+W]>9) && y+1< 3)
{
if(map[x+y*W+W]==0)T_map[x+y*W+W]=8;
if(map[x+y*W+W]>9)T_map[x+y*W+W]=9;
}break;
// ---士---
case 2:if(( map[x-1+y*W-W]==0 || map[x-1+y*W-W] > 9 ) && x - 1 > 2 && y - 1 >= 0 )
{
if(map[x-1+y*W-W]==0)T_map[x-1+y*W-W]=8;
if(map[x-1+y*W-W] > 9)T_map[x-1+y*W-W]=9;
}
if(( map[x+1+y*W+W]==0 || map[x+1+y*W+W] > 9 ) && x+1< 6 && y + 1 < 3 )
{
if(map[x+1+y*W+W]==0)T_map[x+1+y*W+W]=8;
if(map[x+1+y*W+W] > 9)T_map[x+1+y*W+W]=9;
}
if(( map[x+1+y*W-W] == 0 || map[x+1+y*W-W] > 9 ) && x+1< 6 && y-1 >= 0 )
{
if(map[x+1+y*W-W] == 0)T_map[x+1+y*W-W]=8;
if(map[x+1+y*W-W] > 9)T_map[x+1+y*W-W]=9;
}
if(( map[x-1+y*W+W] ==0 || map[x-1+y*W+W] > 9 ) && x - 1 > 2 && y+1< 3 )
{
if(map[x-1+y*W+W] ==0)T_map[x-1+y*W+W] = 8 ;
if(map[x-1+y*W+W] > 9)T_map[x-1+y*W+W] = 9 ;
}break;
// ---象---
case 3:if(( map[x-2+y*W-W-W]==0 || map[x-2+y*W-W-W] > 9 )&& map[x-1+y*W-W]==0 && x - 2 >= 0 && y - 2 >= 0 )
{
if(map[x-2+y*W-W-W]== 0)T_map[x-2+y*W-W-W]=8;
if(map[x-2+y*W-W-W] > 9)T_map[x-2+y*W-W-W]=9;
}
if(( map[x+2+y*W+W+W]==0 || map[x+2+y*W+W+W] > 9)&& map[x+1+y*W+W]==0 && x+2< 9 && y + 2 < 5 )
{
if(map[x+2+y*W+W+W]== 0)T_map[x+2+y*W+W+W]=8;
if(map[x+2+y*W+W+W] > 9)T_map[x+2+y*W+W+W]=9;
}
if(( map[x+2+y*W-W-W] == 0 || map[x+2+y*W-W-W] > 9 )&& map[x+1+y*W-W] == 0 && x+2< 9 && y-2 >= 0 )
{
if(map[x+2+y*W-W-W] == 0)T_map[x+2+y*W-W-W]=8;
if(map[x+2+y*W-W-W] > 9)T_map[x+2+y*W-W-W]=9;
}
if(( map[x-2+y*W+W+W] ==0 || map[x-2+y*W+W+W] > 9 )&& map[x-1+y*W+W] ==0 && x - 2 >= 0 && y+2< 5 )
{
if(map[x-2+y*W+W+W] ==0)T_map[x-2+y*W+W+W] = 8 ;
if(map[x-2+y*W+W+W] > 9)T_map[x-2+y*W+W+W] = 9 ;
}break;
// ---马---
case 4:if(( map[x-2+y*W-W]==0 || map[x-2+y*W-W] > 9 )&& map[x-1+y*W]==0 && x - 2 >= 0 && y - 1 >= 0 )
{
if(map[x-2+y*W-W]== 0)T_map[x-2+y*W-W]=8;
if(map[x-2+y*W-W] > 9)T_map[x-2+y*W-W]=9;
}
if(( map[x-1+y*W-W-W]==0 || map[x-1+y*W-W-W] > 9 )&& map[x+y*W-W]==0 && x - 1 >= 0 && y - 2 >= 0 )
{
if(map[x-1+y*W-W-W]== 0)T_map[x-1+y*W-W-W]=8;
if(map[x-1+y*W-W-W] > 9)T_map[x-1+y*W-W-W]=9;
}
if(( map[x-2+y*W+W]==0 || map[x-2+y*W+W] > 9)&& map[x-1+y*W]==0 && x-2 >= 0 && y + 1 < 10 )
{
if(map[x-2+y*W+W]== 0)T_map[x-2+y*W+W]=8;
if(map[x-2+y*W+W] > 9)T_map[x-2+y*W+W]=9;
}
if(( map[x-1+y*W+W+W]==0 || map[x-1+y*W+W+W] > 9)&& map[x+y*W+W]==0 && x-1 >= 0 && y + 2 < 10 )
{
if(map[x-1+y*W+W+W]== 0)T_map[x-1+y*W+W+W]=8;
if(map[x-1+y*W+W+W] > 9)T_map[x-1+y*W+W+W]=9;
}//--------------------------------------------------------
if(( map[x+2+y*W+W] == 0 || map[x+2+y*W+W] > 9 )&& map[x+1+y*W] == 0 && x+2< 9 && y+1 < 10 )
{
if(map[x+2+y*W+W] == 0)T_map[x+2+y*W+W]=8;
if(map[x+2+y*W+W] > 9)T_map[x+2+y*W+W]=9;
}
if(( map[x+1+y*W+W+W] == 0 || map[x+1+y*W+W+W] > 9 )&& map[x+y*W+W] == 0 && x+1< 9 && y+2 < 10 )
{
if(map[x+1+y*W+W+W] == 0)T_map[x+1+y*W+W+W]=8 ;
if(map[x+1+y*W+W+W] > 9) T_map[x+1+y*W+W+W]=9 ;
}//--------------------------------------------------------
if(( map[x+2+y*W-W] ==0 || map[x+2+y*W-W] > 9 )&& map[x+1+y*W] ==0 && x + 2 < 9 && y-1 >= 0 )
{
if(map[x+2+y*W-W] ==0)T_map[x+2+y*W-W] = 8 ;
if(map[x+2+y*W-W] > 9)T_map[x+2+y*W-W] = 9 ;
}
if(( map[x+1+y*W-W-W] ==0 || map[x+1+y*W-W-W] > 9 )&& map[x+y*W-W] ==0 && x + 1 < 9 && y-2 >= 0 )
{
if(map[x+1+y*W-W-W] ==0)T_map[x+1+y*W-W-W] = 8 ;
if(map[x+1+y*W-W-W] > 9)T_map[x+1+y*W-W-W] = 9 ;
}break;
// ---车---
case 5:while(++x1<9)
{
if(map[x1+y*W]==0)T_map[x1+y*W]= 8;
else if(map[x1+y*W] > 9)
{T_map[x1+y*W]= 9 ;break;}
else break;
}
while(--x2 >= 0)
{
if(map[x2+y*W]==0)T_map[x2+y*W]=8;
else if(map[x2+y*W] > 9)
{T_map[x2+y*W]= 9 ;break;}
else break;
}
while(++y1<10)
{
if(map[x+y1*W]==0)T_map[x+y1*W]=8;
else if(map[x+y1*W] > 9)
{T_map[x+y1*W] = 9;break;}
else break;
}
while(--y2>=0)
{
if(map[x+y2*W]==0)T_map[x+y2*W]=8;
else if((map[x+y2*W] > 9)&& px==x1 && py==y)
{T_map[x+y2*W]= 9 ;break;}
else break;
}break;
case 6:while(++x1<9)// ---炮---
{ t=x1+y*W;
if(map[t] != 0 && pao1 == 9 )
pao1=x1;
if( map[t]==0 && pao1 > x1) T_map[t]=8;
if( x1 > pao1 )
{
if(map[t] < 8 && map[t] != 0)break;
else if(map[t] > 9 )
{
T_map[t]= 9 ;break;
}
}
}
while(--x2 >= 0)
{ t=x2+y*W;
if(map[t] != 0 && pao2 == 0 )
pao2=x2;
if( map[t]==0 && pao2 <= x2)T_map[t]=8;
if( x2 < pao2)
{
if(map[t] < 8 && map[t] != 0)break;
else if(map[t] > 9 )
{
T_map[t]= 9 ;break;
}
}
}
while(++y1<10)
{ t=x+y1*W;
if(map[t] != 0 && pao3 == 10 )
pao3=y1;
if( map[t]==0 && pao3 > y1 )T_map[t]=8;
if( y1 > pao3)
{
if(map[t] < 8 && map[t] != 0)break;
else if(map[t] > 9 )
{
T_map[t]= 9 ;break;
}
}
}
while(--y2>=0)
{ t=x+y2*W;
if(map[t] != 0 && pao4 == 0 )
pao4=y2;
if( map[t]==0 && pao4 <= y2 )T_map[t]=8;
if( y2 < pao4)
{
if(map[t] < 8 && map[t] != 0)break;
else if(map[t] > 9 )
{
T_map[t]= 9 ;break;
}
}
}break;
// ---兵---
case 7:if((map[x-1+y*W]==0 || map[x-1+y*W]>9) && y > 4)
{
if(map[x-1+y*W]==0)T_map[x-1+y*W]=8;
if(map[x-1+y*W]>9)T_map[x-1+y*W]= 9 ;
}
if((map[x+1+y*W]==0 || map[x+1+y*W]>9) && y > 4)
{
if(map[x+1+y*W]==0)T_map[x+1+y*W]=8;
if(map[x+1+y*W]>9)T_map[x+1+y*W]= 9 ;
}
if(map[x+y*W+W]==0 || map[x+y*W+W]>9)
{
if(map[x+y*W+W]==0)T_map[x+y*W+W]=8;
if(map[x+y*W+W]>9)T_map[x+y*W+W]= 9 ;
}break;
// ---将---
case 11:if((map[x-1+y*W]==0 || map[x-1+y*W]>9) && x-1> 2)
{ t=x-1+y*W;
if(map[t]==0)T_map[t]=8;
if(map[t]<9 && map[t] !=0)T_map[t]= 9 ;
}
if((map[x+1+y*W]==0 || map[x+1+y*W]<9) && x+1< 6)
{ t=x+1+y*W;
if(map[t]==0)T_map[t]=8;
if(map[t]<9 && map[t] !=0)T_map[t]= 9 ;
}
if((map[x+y*W-W] == 0 || map[x+y*W-W]<9) && y-1>= 7)
{ t=x+y*W-W;
if(map[t] == 0)T_map[t]=8;
if(map[t]<9 && map[t] !=0)T_map[t]= 9 ;
}
if((map[x+y*W+W]==0 || map[x+y*W+W]<9) && y+1< 10)
{ t=x+y*W+W;
if(map[t]==0)T_map[t]=8;
if(map[t]<9 && map[t] !=0)T_map[t]= 9 ;
}break;
// ---士---
case 12:if(( map[x-1+y*W-W]==0 || map[x-1+y*W-W] < 9 ) && x - 1 > 2 && y - 1 > 6 )
{ t=x-1+y*W-W;
if(map[t]==0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x+1+y*W+W]==0 || map[x+1+y*W+W] < 9 ) && x+1< 6 && y + 1 < 10 )
{ t=x+1+y*W+W;
if(map[t]==0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x+1+y*W-W] == 0 || map[x+1+y*W-W] < 9 ) && x+1< 6 && y-1 > 6 )
{ t=x+1+y*W-W;
if(map[t] == 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x-1+y*W+W] ==0 || map[x-1+y*W+W] < 9 ) && x - 1 > 2 && y+1< 10 )
{ t=x-1+y*W+W;
if(map[t] ==0)T_map[t] = 8 ;
if(map[t] < 9 && map[t] !=0)T_map[t] = 9 ;
}break;
// ---相---
case 13:if(( map[x-2+y*W-W-W]==0 || map[x-2+y*W-W-W] < 9 )&& map[x-1+y*W-W]==0 && x - 2 >= 0 && y - 2 > 4 )
{ t=x-2+y*W-W-W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] != 0)T_map[t]=9;
}
if(( map[x+2+y*W+W+W]==0 || map[x+2+y*W+W+W] < 9)&& map[x+1+y*W+W]==0 && x+2< 9 && y + 2 < 10 )
{ t=x+2+y*W+W+W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] != 0)T_map[t]=9;
}
if(( map[x+2+y*W-W-W] == 0 || map[x+2+y*W-W-W] < 9 )&& map[x+1+y*W-W] == 0 && x+2< 9 && y-2 > 4 )
{ t=x+2+y*W-W-W;
if(map[t] == 0)T_map[t]=8;
if(map[t] < 9 && map[t] != 0)T_map[t]=9;
}
if(( map[x-2+y*W+W+W] ==0 || map[x-2+y*W+W+W] < 9 )&& map[x-1+y*W+W] ==0 && x - 2 >= 0 && y+2< 10 )
{ t=x-2+y*W+W+W;
if(map[t] ==0)T_map[t] = 8 ;
if(map[t] < 9 && map[t] != 0)T_map[t] = 9 ;
}break;
// ---马---
case 14:if(( map[x-2+y*W-W]==0 || map[x-2+y*W-W] < 9 )&& map[x-1+y*W]==0 && x - 2 >= 0 && y - 1 >= 0 )
{ t=x-2+y*W-W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x-1+y*W-W-W]==0 || map[x-1+y*W-W-W] < 9 )&& map[x+y*W-W]==0 && x - 1 >= 0 && y - 2 >= 0 )
{ t=x-1+y*W-W-W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x-2+y*W+W]==0 || map[x-2+y*W+W] < 9)&& map[x-1+y*W]==0 && x-2 >= 0 && y + 1 < 10 )
{ t=x-2+y*W+W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x-1+y*W+W+W]==0 || map[x-1+y*W+W+W] < 9)&& map[x+y*W+W]==0 && x-1 >= 0 && y + 2 < 10 )
{ t=x-1+y*W+W+W;
if(map[t]== 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}//--------------------------------------------------------
if(( map[x+2+y*W+W] == 0 || map[x+2+y*W+W] < 9 )&& map[x+1+y*W] == 0 && x+2< 9 && y+1 < 10 )
{ t=x+2+y*W+W;
if(map[t] == 0)T_map[t]=8;
if(map[t] < 9 && map[t] !=0)T_map[t]=9;
}
if(( map[x+1+y*W+W+W] == 0 || map[x+1+y*W+W+W] < 9 )&& map[x+y*W+W] == 0 && x+1< 9 && y+2 < 10 )
{ t=x+1+y*W+W+W;
if(map[t] == 0)T_map[t]=8 ;
if(map[t] < 9 && map[t] !=0) T_map[t]=9 ;
}//--------------------------------------------------------
if(( map[x+2+y*W-W] ==0 || map[x+2+y*W-W] < 9 )&& map[x+1+y*W] ==0 && x + 2 < 9 && y-1 >= 0 )
{ t=x+2+y*W-W;
if(map[t] ==0)T_map[t] = 8 ;
if(map[t] < 9 && map[t] !=0)T_map[t] = 9 ;
}
if(( map[x+1+y*W-W-W] ==0 || map[x+1+y*W-W-W] < 9 )&& map[x+y*W-W] ==0 && x + 1 < 9 && y-2 >= 0 )
{ t=x+1+y*W-W-W;
if(map[t] ==0)T_map[t] = 8 ;
if(map[t] < 9 && map[t] !=0)T_map[t] = 9 ;
}break;
// ---车---
case 15:while(++x1<9)
{
if(map[x1+y*W]==0)T_map[x1+y*W]= 8;
else if(map[x1+y*W] < 9 &&map[x+y2*W] != 0)
{T_map[x1+y*W]= 9 ;break;}
else break;
}
while(--x2 >= 0)
{
if(map[x2+y*W]==0)T_map[x2+y*W]=8;
else if(map[x2+y*W] < 9 && map[x+y2*W] != 0)
{T_map[x2+y*W]= 9 ;break;}
else break;
}
while(++y1<10)
{
if(map[x+y1*W]==0)T_map[x+y1*W]=8;
else if(map[x+y1*W] < 9 && map[x+y2*W] != 0)
{T_map[x+y1*W] = 9;break;}
else break;
}
while(--y2>=0)
{
if(map[x+y2*W]==0)T_map[x+y2*W]=8;
else if(map[x+y2*W] < 9 && map[x+y2*W] != 0)
{T_map[x+y2*W]= 9 ;break;}
else break;
}break;
// ---泡---
case 16:while(++x1<9)
{
t=x1+y*W;
if(map[t] != 0 && pao1 == 9 )
pao1=x1;
if( map[t]==0 && pao1 > x1) T_map[t]=8;
if( x1 > pao1 )
{
if(map[t] > 9)break;
if(map[t] < 9 && map[t] != 0)
{
T_map[t]= 9 ;break;
}
}
}
while(--x2 >= 0)
{ t=x2+y*W;
if(map[t] != 0 && pao2 == 0 )
pao2=x2;
if( map[t]==0 && pao2 <= x2)T_map[t]=8;
if( x2 < pao2)
{
if(map[t] > 8)break;
if(map[t] < 9 && map[t] != 0)
{
T_map[t]= 9 ;break;
}
}
}
while(++y1<10)
{ t=x+y1*W;
if(map[t] != 0 && pao3 == 10 )
pao3=y1;
if( map[t]==0 && pao3 > y1 )T_map[t]=8;
if( y1 > pao3)
{
if(map[t] > 8)break;
if(map[t] < 9 && map[t] != 0)
{
T_map[t]= 9 ;break;
}
}
}
while(--y2>=0)
{ t=x+y2*W;
if(map[t] != 0 && pao4 == 0 )
pao4=y2;
if( map[t]==0 && pao4 <= y2 )T_map[t]=8;
if( y2 < pao4)
{
if(map[t] > 8)break;
if(map[t] < 8 && map[t] != 0)
{
T_map[t]= 9 ;break;
}
}
}break;
// ---卒---
case 17:if((map[x-1+y*W]==0 || map[x-1+y*W]<9) && y < 5)
{
if(map[x-1+y*W]==0)T_map[x-1+y*W]=8;
else if(map[x-1+y*W]<8)T_map[x-1+y*W]= 9 ;
}
if((map[x+1+y*W]==0 || map[x+1+y*W]<9) && y < 5)
{
if(map[x+1+y*W]==0)T_map[x+1+y*W]=8;
else if(map[x+1+y*W]<8)T_map[x+1+y*W]= 9 ;
}
if(map[x+y*W-W]==0 || map[x+y*W-W]<9)
{
if(map[x+y*W-W]==0)T_map[x+y*W-W]=8;
else if(map[x+y*W-W]<8)T_map[x+y*W-W]= 9 ;
}break;
}
}
void whowin()
{
for(int y=0;y<3;++y)
{
for(int x=3;x<6;++x)
{
if(map[x+y*W]!=1)
black=true;
if(map[x+y*W]==1)
{black=false;break;}
}
if(!black) break;
}
for(int y=7;y<10;++y) //--------------????
{
for(int x=3;x<6;++x)
{
if(map[x+y*W] != 11)
red=true;
if( map[x+y*W] == 11 )
{red=false;return;}
}
}
}
只能说,耐性还是足够的!