forked from zhangjinxing/Renju-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
628 lines (617 loc) · 16.5 KB
/
main.c
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
/*大一时写的代码,拿爪机敲的,排版差见谅。。。*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>
#define H 26 //H为奇数,棋盘大小
#define up 'w'
#define down 's'
#define left 'a'
#define right 'd'
#define ok 'j' //落子是j
int x,y,nextx,nexty,wint,turn,now,you,maxm=0,maxy=0,maxmcoordx=0,maxmcoordy=0,maxycoordx=0,maxycoordy=0,map[H][H];
void init_map_array() //初始化map棋盘数组
{
system("cls");
int i,j;
for(i=0;i<H;i++)
for(j=0;j<H;j++)
map[i][j]=9;
x=H/2,y=H/2;
for(i=4;i<H-4;i++)
for(j=4;j<H-4;j++)
map[i][j]=4;
map[x][y]=3;
}
void drawMap() //显示棋盘界面
{
int i,j;
for(i=4;i<H-4;i++)
{
for(j=4;j<H-4;j++)
{
if (map[i][j]==4)
{
if (i==4&&j==4) printf("\t┏");
else if (i==4&&j==H-5) printf("┓");
else if (i==H-5&&j==4) printf("\t┗");
else if (i==H-5&&j==H-5) printf("┛");
else
{
switch(j)
{
case H-5:printf("┫");break;
case 4 :printf("\t┣");break;
default :
switch (i)
{
case 4 :printf("┳");break;
case H-5:printf("┻");break;
default :printf("╋");break;
}
break;
}
}
}
if (map[i][j]==1)
printf("●");
if (map[i][j]==0)
printf("○");
if (map[i][j]==3)
printf("Ⅹ");
}
printf("\n");
}
printf("══════════════════════════\n");
}
void swap()
{
int temp;
temp=map[nextx][nexty];
map[nextx][nexty]=map[x][y];
map[x][y]=temp;
x=nextx,y=nexty;
}
void playchoice()
{
void AI();
int t=0;
char i;
try_again:
while(!kbhit())
{
i=getch();
if (i==up||i==down||i==left||i==right||i==ok)
break;
}
while(kbhit())
{
i=getch();
}
switch(i)
{
case left: /*第一个if防止光标和黑白子交换,第二个if防止当前坐标变成黑白子,跟着走*/
nextx=x;
if (y==4)
goto try_again;
else
nexty=y-1;
if (map[x][y]==1||map[x][y]==0)
{
if (!(map[nextx][nexty]==1||map[nextx][nexty]==0))
map[nextx][nexty]=3;
x=nextx,y=nexty;
break;
}
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
{
map[x][y]=4;
x=nextx,y=nexty;
break;
}
swap();break;
case right:
nextx=x;
if (y==H-5)
goto try_again;
else
nexty=y+1;
if (map[x][y]==1||map[x][y]==0)
{
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
;
else
map[nextx][nexty]=3;
x=nextx,y=nexty;
break;
}
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
{
map[x][y]=4;
x=nextx,y=nexty;
break;
}
swap();break;
case up:
if (x==4)
goto try_again;
else
nextx=x-1;
nexty=y;
if (map[x][y]==1||map[x][y]==0)
{
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
;
else
map[nextx][nexty]=3;
x=nextx,y=nexty;
break;
}
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
{
map[x][y]=4;
x=nextx,y=nexty;
break;
}
swap();break;
case down:
if (x==H-5)
goto try_again;
else
nextx=x+1;
nexty=y;
if (map[x][y]==1||map[x][y]==0)
{
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
;
else
map[nextx][nexty]=3;
x=nextx,y=nexty;
break;
}
if (map[nextx][nexty]==1||map[nextx][nexty]==0)
{
map[x][y]=4;
x=nextx,y=nexty;
break;
}
swap();
break;
case ok:
if (map[x][y]==0||map[x][y]==1)
goto try_again;
else
{
map[x][y]=1;
system("cls");
drawMap();
//Sleep(800);
AI();
system("cls");
drawMap();
return;
}
break;
default:break;
}
system("cls");
drawMap();
}
int iswin()
{
int i,j,time=1,xi,yi;
for(i=4;i<H-4;i++)
for(j=4;j<H-4;j++)
{
if(map[i][j]==1||map[i][j]==0)
{
if(map[i][j]==0)
wint=0;
else
wint=1;
xi=i,yi=j;
while(yi<H-4&&yi>3)
{
yi++;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3)
{
yi--;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3)
{
xi++;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3)
{
xi--;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3&&yi<H-4&&yi>3)
{
xi++,yi++;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3&&yi<H-4&&yi>3)
{
xi++,yi--;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3&&yi<H-4&&yi>3)
{
xi--,yi--;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
xi=i,yi=j;
while(xi<H-4&&xi>3&&yi<H-4&&yi>3)
{
xi--,yi++;
if (map[xi][yi]==wint)
{
time++;
if (time==5)
return 0;
}
else break;
}
time=1;
}
}
return 1;
}
void compare()
{
int i,j,score=0,coord[H*H][2]={0},max=0,t=0;//t来计数
for (i=4;i<H-4;i++)
{
for(j=4;j<H-4;j++)
{
//遍历没一个格子
if (map[i][j]==4)
{//如果当前是空格
if (map[i+1][j]==now||map[i][j+1]==now||map[i+1][j+1]==now||map[i-1][j+1]==now||map[i+1][j-1]==now||map[i-1][j-1]==now||map[i][j-1]==now||map[i-1][j]==now) //这里八个方向遍历
//如果当前的空格下个有子
{
//右活一
if (map[i][j+1]==now&&map[i][j+2]==4)
score+=20;
//右死一
if (map[i][j+1]==now&&map[i][j+2]==9||map[i][j+1]==now&&map[i][j+2]==you)
score+=4;
//右活二
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==4)
score+=400;
//右死二
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==9||map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==you)
score+=90;
//右活三
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==4)
score+=6000;
//右死三
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==you||map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==9)
score+=800;
//右活四
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==now&&map[i][j+5]==4)
score+=20000;
//右死四
if (map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==now&&map[i][j+5]==you||map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==now&&map[i][j+4]==now&&map[i][j+5]==9)
score+=10000;
//左活一
if (map[i][j-1]==now&&map[i][j-2]==4)
score+=20;
//左死一
if (map[i][j-1]==now&&map[i][j-2]==you||map[i][j-1]==0&&map[i][j-2]==9)
score+=4;
//左活二
if (map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==4)
score+=400;
//左死二
if (map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==you||map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==9)
score+=90;
//左活三
if (map[i][j-1]==you&&map[i][j-2]==you&&map[i][j-3]==you&&map[i][j-4]==4)
score+=6000;
//左死三
if (map[i][j-1]==0&&map[i][j-2]==0&&map[i][j-3]==0&&map[i][j-4]==you||map[i][j-1]==0&&&map[i][j-2]==0&&map[i][j-3]==0&&map[i][j-4]==9)
score+=800;
//左活四
if (map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==now&&map[i][j-4]==now&&map[i][j-5]==4)
score+=20000;
//左死四
if (map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==now&&map[i][j-4]==now&&map[i][j-5]==you||map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==now&&map[i][j-4]==now&&map[i][j-5]==9)
score+=10000;
//下活一
if (map[i+1][j]==now&&map[i+2][j]==4)
score+=20;
//下死一
if (map[i+1][j]==now&&map[i+2][j]==you||map[i+1][j]==now&&map[i+2][j]==9)
score+=4;
//下活二
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==4)
score+=400;
//下死二
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==9||map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==you)
score+=90;
//下活三
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==4)
score+=6000;
//下死三
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==you||map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==9)
score+=800;
//下活四
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==now&&map[i+5][j]==4)
score+=20000;
//下死四
if (map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==now&&map[i+5][j]==you||map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==now&&map[i+4][j]==now&&map[i+5][j]==9)
score+=10000;
//上活一
if (map[i-1][j]==now&&map[i-2][j]==4)
score+=20;
//上死一
if (map[i-1][j]==now&&map[i-2][j]==you||map[i-1][j]==now&&map[i-2][j]==9)
score+=4;
//上活二
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i][j-3]==4)
score+=400;
//上死二
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==9||map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==you)
score+=90;
//上活三
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==4)
score+=6000;
//上死三
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==you||map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==9)
score+=800;
//上活四
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==now&&map[i-5][j]==4)
score+=20000;
//上死四
if (map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==now&&map[i-5][j]==you||map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==now&&map[i-4][j]==now&&map[i-5][j]==9)
score+=10000;
//右下活一
if (map[i+1][j+1]==now&&map[i+2][j+2]==4)
score+=20;
//右下死一
if (map[i+1][j+1]==now&&map[i+2][j+2]==9||map[i+1][j+1]==now&&map[i+2][j+2]==you)
score+=4;
//右下活二
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==4)
score+=400;
//右下死二
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==9||map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==you)
score+=90;
//右下活三
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==4)
score+=6000;
//右下死三
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==you||map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==9)
score+=800;
//右下活四
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==now&&map[i+5][j+5]==4)
score+=20000;
//右下死四
if (map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==now&&map[i+5][j+5]==you||map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==now&&map[i+4][j+4]==now&&map[i+5][j+5]==9)
score+=10000;
//左上活一
if (map[i-1][j-1]==now&&map[i-2][j-2]==4)
score+=20;
//左上死一
if (map[i-1][j-1]==now&&map[i-2][j-2]==9||map[i-1][j-1]==now&&map[i-2][j-2]==you)
score+=4;
//左上活二
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==4)
score+=400;
//左上死二
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==9||map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==you)
score+=90;
//左上活三
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==4)
score+=6000;
//左上死三
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==you||map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==9)
score+=800;
//左上活四
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==now&&map[i-5][j-5]==4)
score+=20000;
//左上死四
if (map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==now&&map[i-5][j-5]==you||map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==now&&map[i-4][j-4]==now&&map[i-5][j-5]==9)
score+=10000;
//左下活一
if (map[i+1][j-1]==now&&map[i+2][j-2]==4)
score+=20;
//左下死一
if (map[i+1][j-1]==now&&map[i+2][j-2]==you||map[i+1][j-1]==now&&map[i+2][j-2]==9)
score+=4;
//左下活二
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==4)
score+=400;
//左下死二
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==9||map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==you)
score+=90;
//左下活三
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==4)
score+=6000;
//左下死三
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==you||map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==9)
score+=800;
//左下活四
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==now&&map[i+5][j-5]==4)
score+=20000;
//左下死四
if (map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==now&&map[i+5][j-5]==you||map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==now&&map[i+4][j-4]==now&&map[i+5][j-5]==9)
score+=10000;
//右上活一
if (map[i-1][j+1]==now&&map[i-2][j+2]==4)
score+=20;
//右上死一
if (map[i-1][j+1]==now&&map[i-2][j+2]==you||map[i-1][j+1]==now&&map[i-2][j+2]==9)
score+=4;
//右上活二
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==4)
score+=400;
//右上死二
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==9||map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==you)
score+=90;
//右上活三
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==4)
score+=6000;
//右上死三
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==you||map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==9)
score+=800;
//右上活四
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==now&&map[i-5][j+5]==4)
score+=20000;
//右上死四
if (map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==now&&map[i-5][j+5]==you||map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==now&&map[i-4][j+4]==now&&map[i-5][j+5]==9)
score+=10000;
if (
map[i][j-1]==now&&map[i][j-2]==now&&map[i][j-3]==4&&map[i][j+1]==now&&map[i][j+2]==4||
map[i][j+1]==now&&map[i][j+2]==now&&map[i][j+3]==4&&map[i][j-1]==now&&map[i][j-2]==4||
map[i-1][j]==now&&map[i-2][j]==now&&map[i-3][j]==4&&map[i+1][j]==now&&map[i+2][j]==4||
map[i+1][j]==now&&map[i+2][j]==now&&map[i+3][j]==4&&map[i-1][j]==now&&map[i-2][j]==4||
map[i-1][j-1]==now&&map[i-2][j-2]==now&&map[i-3][j-3]==4&&map[i+1][j+1]==now&&map[i+2][j+2]==4||
map[i+1][j+1]==now&&map[i+2][j+2]==now&&map[i+3][j+3]==4&&map[i-1][j-1]==now&&map[i-2][j-2]==4||
map[i+1][j-1]==now&&map[i+2][j-2]==now&&map[i+3][j-3]==4&&map[i-1][j+1]==now&&map[i-2][j+2]==4||
map[i-1][j+1]==now&&map[i-2][j+2]==now&&map[i-3][j+3]==4&&map[i+1][j-1]==now&&map[i+2][j-2]==4)
score+=5580;
}
}
//下活一
if (score<max)
score=0;
if (score==max)
{
t++;
coord[t][0]=i,coord[t][1]=j;
score=0;
}
if (score>max)
{
t=0;
coord[t][0]=i,coord[t][1]=j;
max=score;
score=0;
}
}
}
if (turn==1)
{
maxm=max;
i=rand()%(t+1);
maxmcoordx=coord[i][0];
maxmcoordy=coord[i][1];
turn=2;
now=1,you=0;
compare();
}
else
{
maxy=max;
i=rand()%(t+1);
maxycoordx=coord[i][0];
maxycoordy=coord[i][1];
}
}
void AI()
{
now=0,you=1;
turn=1;
compare();
if (maxm>maxy)
map[maxmcoordx][maxmcoordy]=0;
if (maxm<maxy)
map[maxycoordx][maxycoordy]=0;
if (maxm==maxy)
{
now=rand()%1;
if (now==1)
map[maxycoordx][maxycoordy]=0;
else
map[maxmcoordx][maxmcoordy]=0;
}
system("cls");
drawMap();
}
void Run()
{
while (iswin())
playchoice();
if (wint==1)
printf("\n\t\t\t白棋赢了!\n");
else
printf("\n\t\t\t黑棋赢了!\n");
printf("\t\t\t游戏结束!\n\t\t按任意键重新开始\n");
x=getch();
}
int main()
{
printf("\n\n\n\t使用wsad移动,j落子\n");
Sleep(800);
system("cls");
while(!kbhit())
{
init_map_array();
drawMap();
Run();
}
return 0;
}