断断续续写的第一个比较满意的作品,算是C语言的一个小结吧,可惜以现在的能力,要写人机对战现实在觉得困难,以后有机会再来补充吧
#include
#include
#include
#include //getch()、kbhit() 用
#include
#define N 15 //15*15棋盘
#define M 44 //棋盘中最近的两平行线之间的坐标相减距离所得距离
#define Width 930 //画布长宽
#define High 700
#define Bk_bigin_x 10 //背景图片起始点
#define Bk_bigin_y 120
#define Qp_begin_x 281-10 //棋盘左上角在画布上的坐标
#define Qp_begin_y 160-120
enum { wu = 1, hei = 2, bai = 3 }; //棋子情况 无子为wu,黑子为hei,白子为bai
int p[N][N] = { wu }; //记录棋盘落子情况 无子为1,黑子为2,白子为3
int rank[N][N];
int qizi_amount;
int gameover; //判断游戏是否结束
int IsJinshou; //判断黑子是否禁手
enum playerturn { player1, player2 }; //轮到哪一位玩家落子
enum playerturn playerturn; //黑子先下
struct zuobiao
{
int x;
int y;
};
struct zuobiao lz_zuobiao, qp_zuobiao; //第一个用于bottondown的使用;第二个用于jinshou、judgewin的使用。必须使用两个结构,不能只用一个
IMAGE img_bk;
IMAGE img_Black_Chess;
IMAGE img_White_Chess;
IMAGE img_Without_Chess;
MOUSEMSG a; //与鼠标操作有关的结构体
MOUSEMSG b;
FILE *qj_record, *qj_import; //指向写入文件的指针、读取文件的指针--棋子状况为wu,bai ,hei
FILE *lz_record, *lz_import; //落子顺序 1.2.3.....
void drawqp()
{
gameover = 0;//数据初始化
IsJinshou = 0;
playerturn = player1;//五子棋规则,黑先手
qizi_amount = 0;//棋盘上棋子的数量
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
p[i][j] = wu;//棋盘棋子清零
rank[i][j] = 0;//棋盘落子顺序清零
}
//导入相关图片
loadimage(&img_bk, L"C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\五子棋盘.PNG"); //导入背景图片
loadimage(&img_Black_Chess, L"C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\黑2.PNG");//导入黑子图片
loadimage(&img_White_Chess, L"C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\白2.PNG");//导入白子图片
loadimage(&img_Without_Chess, L"C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\无子.PNG");//导入无子图片
putimage(0, 0, Width, High, &img_bk, Bk_bigin_x, Bk_bigin_y); //输出背景图片
setbkmode(TRANSPARENT);
settextcolor(WHITE);
settextstyle(15, 0, _T("黑体"));
outtextxy(20, High*0.7 + 10, L"Tips:");
outtextxy(20, High*0.7 + 30, L"1.按右键重新开局");
outtextxy(20, High*0.7 + 50, L"2.中途退出可保存棋局");
outtextxy(20, High*0.7 + 70, L"3.棋局结束前按鼠标中键可悔棋");
}
void impor_data()
{
//读取棋盘棋子状况信息
if (qj_import = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\棋局.txt", "r"))
{
int pos;
int h = 0, b = 0; //黑子,白子 的数量
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
pos = (long)(i *N + j) * sizeof(int);
fseek(qj_import, pos, SEEK_SET); //定位文件指针的位置
fread(&p[i][j], sizeof(int), 1, qj_import);
if (p[i][j] == hei)
{
putimage(Qp_begin_x + j*M - 20, Qp_begin_y + i*M - 20, &img_Black_Chess);
h++;
}
if (p[i][j] == bai)
{
putimage(Qp_begin_x + j*M - 20, Qp_begin_y + i*M - 20, &img_White_Chess);
b++;
}
}
fclose(qj_import);
if (h == b)
playerturn = player1;
else
playerturn = player2;
}
//读取棋盘落子顺序信息
if (lz_import = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\落子顺序.txt", "r"))
{
int pos;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
pos = (long)(i *N + j) * sizeof(int);
fseek(lz_import, pos, SEEK_SET); //定位文件指针的位置
fread(&rank[i][j], sizeof(int), 1, lz_import);
if (rank[i][j] > qizi_amount)
qizi_amount = rank[i][j];
}
fclose(lz_import);
}
}
void place()
{
a = GetMouseMsg(); //获取鼠标操作信息
for (int i = 0; i < N; i++)
if (abs(Qp_begin_x + i*M - a.x) < M*0.5) { lz_zuobiao.x = i; break; }//确定鼠标最接近的点的坐标
for (int i = 0; i < N; i++)
if (abs(Qp_begin_y + i*M - a.y) < M*0.5) { lz_zuobiao.y = i; break; }
}
void bottondown()
{
if (p[lz_zuobiao.y][lz_zuobiao.x] == wu) //鼠标所对应于棋盘的点为无子时
{
if (a.uMsg == WM_LBUTTONDOWN && playerturn == player1) //点击左键且轮到玩家1
{
p[lz_zuobiao.y][lz_zuobiao.x] = hei;
qp_zuobiao = lz_zuobiao; //为后面判断禁手输赢准备
qizi_amount++;
rank[lz_zuobiao.y][lz_zuobiao.x] = qizi_amount;
putimage(Qp_begin_x + qp_zuobiao.x*M - 20, Qp_begin_y + qp_zuobiao.y*M - 20, &img_Black_Chess);
playerturn = player2; //玩家置换 为下一次到这里的训话做准备
//记录棋局状况
qj_record = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\棋局.txt", "w");
fwrite(p, sizeof(int), N*N, qj_record);//记录下一次落子轮到哪一位玩家
fclose(qj_record);
//记录落子顺序
lz_record = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\落子顺序.txt", "w");
fwrite(rank, sizeof(int), N*N, lz_record);
fclose(lz_record);
}
else if (a.uMsg == WM_LBUTTONDOWN && playerturn == player2)
{
p[lz_zuobiao.y][lz_zuobiao.x] = bai;
qp_zuobiao = lz_zuobiao;
qizi_amount++;
rank[lz_zuobiao.y][lz_zuobiao.x] = qizi_amount;
putimage(Qp_begin_x + qp_zuobiao.x*M - 20, Qp_begin_y + qp_zuobiao.y*M - 20, &img_White_Chess);
playerturn = player1;
//记录棋局状况
qj_record = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\棋局.txt", "w");
fwrite(p, sizeof(int), N*N, qj_record);//记录下一次落子轮到哪一位玩家
fclose(qj_record);
//记录落子顺序
lz_record = fopen("C:\\Users\\pg113\\Desktop\\游戏代码\\素材库\\落子顺序.txt", "w");
fwrite(rank, sizeof(int), N*N, lz_record);
fclose(lz_record);
}
}
}
int jinshou()
{
int count1 = 0, count2 = 0;
//黑子 若禁手 则IsJinshou=1、2、3;
if (playerturn == player2)//说明当前为黑子的下棋
{
//长连禁手
{
//横
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y][qp_zuobiao.x + i] == hei) count1++; else break; }
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y][qp_zuobiao.x - i] == hei) count2++; else break; }
if (count1 + count2 + 1 >= 6) { IsJinshou = 1; return 0; }
count1 = 0; count2 = 0;
//竖
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x] == hei) count1++; else break; }
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x] == hei) count2++; else break; }
if (count1 + count2 + 1 >= 6) { IsJinshou = 1; return 0; }
count1 = 0; count2 = 0;
//左上到右下
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x - i] == hei) count1++; else break; }
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x + i] == hei) count2++; else break; }
if (count1 + count2 + 1 >= 6) { IsJinshou = 1; return 0; }
count1 = 0; count2 = 0;
//右上到左下
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x + i] == hei) count1++; else break; }
for (int i = 1; i <= wu; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x - i] == hei) count2++; else break; }
if (count1 + count2 + 1 >= 6) { IsJinshou = 1; return 0; }
count1 = 0; count2 = 0;
}
//三三禁手
{
int a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0;
int count33 = 0;
//横
{
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu) a1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu) a2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu) b1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu) b2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu) c1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu) c2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu) d1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu) d2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu) e1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu) e2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu) f1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu) f2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) g1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) g2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) h1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) h2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) i1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) i2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) j1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) j2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y][qp_zuobiao.x - wu] == wu) k1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y][qp_zuobiao.x - wu] == wu) k2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y][qp_zuobiao.x - wu] == wu) l1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y][qp_zuobiao.x - wu] == wu) l2 = 1;
if ((c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (a1 == 1 && g2 == 1) || (a2 == 1 && g1 == 1) || (e1 == 1 && b2 == 1) || (e2 == 1 && b1 == 1) || (c1 == 1 && i2 == 1) || (c2 == 1 && i1 == 1) || (a1 == 1 && l2 == 1) || (a2 == 1 && l1 == 1)
|| (c1 == 1 && h2 == 1) || (c2 == 1 && h1 == 1) || (a1 == 1 && k2 == 1) || (a2 == 1 && k1 == 1) || (e1 == 1 && f2 == 1) || (e2 == 1 && f1 == 1) || (b1 == 1 && j2 == 1) || (b2 == 1 && j1 == 1))
count33++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0;
}
//竖
{
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu) a1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu) a2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu) b1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu) b2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu) c1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu) c2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu) d1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu) d2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu) e1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu) e2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu) f1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu) f2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu) g1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu) g2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu) h1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu) h2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu) i1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu) i2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu) j1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu) j2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x] == wu) k1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x] == wu) k2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x] == wu) l1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x] == wu) l2 = 1;
if ((c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (a1 == 1 && g2 == 1) || (a2 == 1 && g1 == 1) || (e1 == 1 && b2 == 1) || (e2 == 1 && b1 == 1) || (c1 == 1 && i2 == 1) || (c2 == 1 && i1 == 1) || (a1 == 1 && l2 == 1) || (a2 == 1 && l1 == 1)
|| (c1 == 1 && h2 == 1) || (c2 == 1 && h1 == 1) || (a1 == 1 && k2 == 1) || (a2 == 1 && k1 == 1) || (e1 == 1 && f2 == 1) || (e2 == 1 && f1 == 1) || (b1 == 1 && j2 == 1) || (b2 == 1 && j1 == 1))
count33++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0;
}
//左上至右下
{
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu) a1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu) a2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu) b1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu) b2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu) c1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu) c2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu) d1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu) d2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu) e1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu) e2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu) f1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu) f2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu) g1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu) g2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu) h1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu) h2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu) i1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu) i2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu) j1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu) j2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x - wu] == wu) k1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x + wu] == wu) k2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x - wu] == wu) l1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x + wu] == wu) l2 = 1;
if ((c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (a1 == 1 && g2 == 1) || (a2 == 1 && g1 == 1) || (e1 == 1 && b2 == 1) || (e2 == 1 && b1 == 1) || (c1 == 1 && i2 == 1) || (c2 == 1 && i1 == 1) || (a1 == 1 && l2 == 1) || (a2 == 1 && l1 == 1)
|| (c1 == 1 && h2 == 1) || (c2 == 1 && h1 == 1) || (a1 == 1 && k2 == 1) || (a2 == 1 && k1 == 1) || (e1 == 1 && f2 == 1) || (e2 == 1 && f1 == 1) || (b1 == 1 && j2 == 1) || (b2 == 1 && j1 == 1))
count33++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0;
}
//右上至左下
{
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu) a1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu) a2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu) b1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu) b2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu) c1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu) c2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu) d1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu) d2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu) e1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu) e2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu) f1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu) f2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu) g1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu) g2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu) h1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu) h2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == 0 && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu) i1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == 0 && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu) i2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == 0 && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu) j1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == 0 && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu) j2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x + wu] == wu) k1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x - wu] == wu) k2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu && p[qp_zuobiao.y - wu][qp_zuobiao.x + wu] == wu) l1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu && p[qp_zuobiao.y + wu][qp_zuobiao.x - wu] == wu) l2 = 1;
if ((c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (a1 == 1 && g2 == 1) || (a2 == 1 && g1 == 1) || (e1 == 1 && b2 == 1) || (e2 == 1 && b1 == 1) || (c1 == 1 && i2 == 1) || (c2 == 1 && i1 == 1) || (a1 == 1 && l2 == 1) || (a2 == 1 && l1 == 1)
|| (c1 == 1 && h2 == 1) || (c2 == 1 && h1 == 1) || (a1 == 1 && k2 == 1) || (a2 == 1 && k1 == 1) || (e1 == 1 && f2 == 1) || (e2 == 1 && f1 == 1) || (b1 == 1 && j2 == 1) || (b2 == 1 && j1 == 1))
count33++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0;
}
if (count33 >= 2) { IsJinshou = 2; return 0; }
}
//四四禁手
{ int a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0, m1 = 0, m2 = 0;
int count44 = 0;
//横
{
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei) a1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei) a2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu) b1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu) b2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei) c1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei) c2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu) d1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu) d2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei) e1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei) e2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei) f1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei) f2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu) g1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu) g2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei) h1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei) h2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei) i1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei) i2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == wu) j1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 4] == wu) j2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 4] == hei) k1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 4] == hei) k2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == hei) l1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 4] == hei) l2 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x - 4] == hei) m1 = 1;
if (p[qp_zuobiao.y][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y][qp_zuobiao.x + 4] == hei) m2 = 1;
if ((g1 == 1 && a2 == 1) || (g2 == 1 && a1 == 1) || (c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (f1 == 1 && b2 == 1) || (f2 == 1 && b1 == 1) || (e1 == 1 && c2 == 1) || (e2 == 1 && c1 == 1) ||
(h1 == 1 && a2 == 1) || (h2 == 1 && a1 == 1) || (a1 == 1 && i2 == 1) || (a2 == 1 && i1 == 1) || (j1 == 1) || (j2 == 1) || (k1 == 1) || (k2 == 1) || (l1 == 1) || (l2 == 1) || (m1 == 1) || (m2 == 1))
count44++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0, m1 = 0, m2 = 0;
}
//竖
{
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei) a1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei) a2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu) b1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu) b2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei) c1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei) c2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu) d1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu) d2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei) e1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei) e2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei) f1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei) f2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu) g1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu) g2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei) h1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei) h2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei) i1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei) i2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x] == wu) j1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x] == wu) j2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x] == hei) k1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x] == hei) k2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x] == hei) l1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x] == hei) l2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x] == hei) m1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x] == hei) m2 = 1;
if ((g1 == 1 && a2 == 1) || (g2 == 1 && a1 == 1) || (c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (f1 == 1 && b2 == 1) || (f2 == 1 && b1 == 1) || (e1 == 1 && c2 == 1) || (e2 == 1 && c1 == 1) ||
(h1 == 1 && a2 == 1) || (h2 == 1 && a1 == 1) || (a1 == 1 && i2 == 1) || (a2 == 1 && i1 == 1) || (j1 == 1) || (j2 == 1) || (k1 == 1) || (k2 == 1) || (l1 == 1) || (l2 == 1) || (m1 == 1) || (m2 == 1))
count44++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0, m1 = 0, m2 = 0;
}
//左上到右下
{
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei) a1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei) a2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu) b1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu) b2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei) c1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei) c2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu) d1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu) d2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei) e1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei) e2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei) f1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei) f2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu) g1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu) g2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei) h1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei) h2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei) i1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei) i2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == wu) j1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == wu) j2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == hei) k1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == hei) k2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == hei) l1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == hei) l2 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x - 4] == hei) m1 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x + 4] == hei) m2 = 1;
if ((g1 == 1 && a2 == 1) || (g2 == 1 && a1 == 1) || (c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (f1 == 1 && b2 == 1) || (f2 == 1 && b1 == 1) || (e1 == 1 && c2 == 1) || (e2 == 1 && c1 == 1) ||
(h1 == 1 && a2 == 1) || (h2 == 1 && a1 == 1) || (a1 == 1 && i2 == 1) || (a2 == 1 && i1 == 1) || (j1 == 1) || (j2 == 1) || (k1 == 1) || (k2 == 1) || (l1 == 1) || (l2 == 1) || (m1 == 1) || (m2 == 1))
count44++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0, m1 = 0, m2 = 0;
}
//右上到左下
{
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei) a1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei) a2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu) b1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu) b2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei) c1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei) c2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu) d1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu) d2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei) e1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei) e2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei) f1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei) f2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu) g1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu) g2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei) h1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei) h2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei) i1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei) i2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == wu) j1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == wu) j2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == wu && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == hei) k1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == wu && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == hei) k2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == hei && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == wu && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == hei) l1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == hei && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == wu && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == hei) l2 = 1;
if (p[qp_zuobiao.y + 1][qp_zuobiao.x - 1] == wu && p[qp_zuobiao.y + 2][qp_zuobiao.x - 2] == hei && p[qp_zuobiao.y + 3][qp_zuobiao.x - 3] == hei && p[qp_zuobiao.y + 4][qp_zuobiao.x - 4] == hei) m1 = 1;
if (p[qp_zuobiao.y - 1][qp_zuobiao.x + 1] == wu && p[qp_zuobiao.y - 2][qp_zuobiao.x + 2] == hei && p[qp_zuobiao.y - 3][qp_zuobiao.x + 3] == hei && p[qp_zuobiao.y - 4][qp_zuobiao.x + 4] == hei) m2 = 1;
if ((g1 == 1 && a2 == 1) || (g2 == 1 && a1 == 1) || (c1 == 1 && d2 == 1) || (c2 == 1 && d1 == 1) || (f1 == 1 && b2 == 1) || (f2 == 1 && b1 == 1) || (e1 == 1 && c2 == 1) || (e2 == 1 && c1 == 1) ||
(h1 == 1 && a2 == 1) || (h2 == 1 && a1 == 1) || (a1 == 1 && i2 == 1) || (a2 == 1 && i1 == 1) || (j1 == 1) || (j2 == 1) || (k1 == 1) || (k2 == 1) || (l1 == 1) || (l2 == 1) || (m1 == 1) || (m2 == 1))
count44++;
a1 = 0, a2 = 0, b1 = 0, b2 = 0, c1 = 0, c2 = 0, d1 = 0, d2 = 0, e1 = 0, e2 = 0,
f1 = 0, f2 = 0, g1 = 0, g2 = 0, h1 = 0, h2 = 0, i1 = 0, i2 = 0, j1 = 0, j2 = 0,
k1 = 0, k2 = 0, l1 = 0, l2 = 0, m1 = 0, m2 = 0;
}
if (count44 >= 2) { IsJinshou = 3; return 0; }
}
}
}
int judgewin()
{
int win = 0, wuzi = 0, count1 = 0, count2 = 0;//win 判断是否赢(连成五子),为1时,则是
int judgepalyer;
if (playerturn == player1) judgepalyer = bai; //bottondown 之后的palyerturn 置换 ;黑子下完后palyerturn 为player2
else if (playerturn == player2)judgepalyer = hei;
//横
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y][qp_zuobiao.x - i] == judgepalyer) count1++; else break; }
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y][qp_zuobiao.x + i] == judgepalyer) count2++; else break; }
if (count1 + count2 + 1 >= 5) { wuzi = 1; }
else { count1 = 0; count2 = 0; }//为下面其他方向的检测准备
//竖
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x] == judgepalyer) count1++; else break; }
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x] == judgepalyer) count2++; else break; }
if (count1 + count2 + 1 >= 5) { wuzi = 1; }
else { count1 = 0; count2 = 0; }
//左上右下
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x - i] == judgepalyer) count1++; else break; }
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x + i] == judgepalyer) count2++; else break; }
if (count1 + count2 + 1 >= 5) { wuzi = 1; }
else { count1 = 0; count2 = 0; }
//右上 左下
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y - i][qp_zuobiao.x + i] == judgepalyer) count1++; else break; }
for (int i = 1; i <= 4; i++) { if (p[qp_zuobiao.y + i][qp_zuobiao.x - i] == judgepalyer) count2++; else break; }
if (count1 + count2 + 1 >= 5) { wuzi = 1; }
else { count1 = 0; count2 = 0; }
if (wuzi)
{
settextcolor(GREEN);
settextstyle(30, 0, _T("黑体"));
if (judgepalyer == hei)outtextxy(Width*0.5 + 100, High*0.6, L"黑赢");
else if (judgepalyer == bai) { outtextxy(Width*0.5 + 100, High*0.6, L"白赢"); }
outtextxy(Width*0.5 - 30, High*0.7, L"按鼠标右键,则重新开局");
gameover = 1;//游戏结束的标志,为后面的结束做准备
return 0;
}
if (IsJinshou >= 1)//若没有连成五子,而黑子禁手,则提前结束
{
settextcolor(GREEN);
settextstyle(30, 0, _T("黑体"));
if (IsJinshou == 1)
outtextxy(Width*0.5, High*0.6, L"黑子长连禁手,白赢");
if (IsJinshou == 2)
outtextxy(Width*0.5, High*0.6, L"黑子三三禁手,白赢");
if (IsJinshou == 3)
outtextxy(Width*0.5, High*0.6, L"黑子四四禁手,白赢");
outtextxy(Width*0.5 - 30, High*0.7, L"按鼠标右键,则重新开局");
gameover = 1; //游戏结束的标志,为后面的结束做准备
return 0;
}
return 0;
}
void end()
{
a = GetMouseMsg();
while (a.uMsg == WM_RBUTTONDOWN)
{
//若想在连成五子关闭后再次打开时没有上一棋局,可在这里修改,把两文件内容归零,
drawqp();
break;
}
}
int huiqi()
{
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
{
if (rank[i][j] == qizi_amount)
{
p[i][j] = wu;
rank[i][j] = 0;
qizi_amount-=1;
putimage(Qp_begin_x + j*M - 20, Qp_begin_y + i*M - 20, 40, 40, &img_bk, 281 + j*M - 20, 160 + i*M - 20);
if (playerturn == player1)
playerturn = player2;
else playerturn = player1;
return 0;
}
}
}
void main()
{
initgraph(Width, High); //创建画布 // 获得窗口句柄
HWND hWnd = GetHWnd();
// 使用 API 函数修改窗口名称
SetWindowText(hWnd, L"五子棋");
drawqp(); //绘制棋盘及相关变量初始化
impor_data(); //导入中途关闭的棋局
while (1)
{
place(); //手机鼠标最接近落子点的坐标信息
bottondown(); //有敲击操作时落子,并记录棋盘信息
jinshou(); //判断是否禁手,若是,则IsJinshou=1,、2、3;
judgewin(); //判断是否结束并输出有关信息
while (gameover)
{
end(); //进入死循环,若按下鼠标中键,则重新开局
}
if (a.uMsg == WM_RBUTTONDOWN) //除结束外任意时刻按下鼠标右键,可重新开局
drawqp();
if (a.uMsg == WM_MBUTTONDOWN)
huiqi();
}
}
效果展示视频:点这里(视频中有一处错误,代码已经改正好了)
文件下载地址
链接:https://pan.baidu.com/s/1S2TUifv42Zngq40rzV6SVA 密码:4wgk