-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.java
132 lines (126 loc) · 2.43 KB
/
board.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
public class board
{
boolean checkm_status;
public static piece pic[][]= new piece[8][8];
public static piece store_i;
public static piece store_f;
public static piece store_k;
public static piece store_p;
player ply1 =new player('B');
player ply2 =new player('W');
int win_s=0;
int if_check=0;
int win_status()
{
int f=0;
ply1.creat_empty();
while(checkm_status == false)
{
if(f!=1)
{
display();
int p1_c=ply2.play_chance();
if(p1_c==1)
continue;
if_check=ply1.check(1);
//if_check=ply1.check_mate(1);
if(if_check==1)
{
checkm_status=true;
win_s=2;
}
if(checkm_status == true)
break;
}
f=0;
display();
int p2_c=ply1.play_chance();
if(p2_c==1)
{
f=1;
continue;
}
if_check=ply2.check(2);
//if_check=ply2.check_mate(1);
if(if_check==1)
{
checkm_status=true;
win_s=1;
}
}
return win_s;
}
void display()
{
System.out.println();
System.out.printf(" ");
for(int i=0;i<8;i++)
System.out.printf(" %d ",i);
System.out.println();
for(int i=0;i<8;i++)
{
System.out.printf(" %d:- ",i);
for(int j=0;j<8;j++)
{
String name= pic[i][j].class_name();
if(name=="king")
{
if(pic[i][j].colour=='B')
System.out.printf("kigB ");
else
System.out.printf("kigW ");
}
else if(name=="queen")
{
if(pic[i][j].colour=='B')
System.out.printf("qunB ");
else
System.out.printf("qunW ");
}
else if(name=="pawn")
{
if(pic[i][j].colour=='B')
System.out.printf("pwnB ");
else
System.out.printf("pwnW ");
}
else if(name=="knight")
{
if(pic[i][j].colour=='B')
System.out.printf("kntB ");
else
System.out.printf("kntW ");
}
else if(name=="rook")
{
if(pic[i][j].colour=='B')
System.out.printf("rokB ");
else
System.out.printf("rokW ");
}
else if(name=="bishup")
{
if(pic[i][j].colour=='B')
System.out.printf("bspB ");
else
System.out.printf("bspW ");
}
else if(name=="pic_ins")
{
if(pic[i][j].colour=='X')
System.out.printf(" x ");
else
System.out.printf(" x ");
}
}
System.out.printf("-:%d ",i);
System.out.println();
System.out.println();
}
System.out.printf(" ");
for(int i=0;i<8;i++)
System.out.printf(" %d ",i);
System.out.println();
System.out.println();
}
}