有谁能帮我写个五子棋人工智能部分 本帖最后由 r4141496091 于 2009-06-13 19:57:46 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 boolean flag = false; // 保存共有相同颜色多少棋子相连 int count = 1; // 判断横向是否有5个棋子相连,特点 纵坐标 是相同, 即allChess[x][y]中y值是相同 int color = allChess[x][y]; /* * if (color == allChess[x+1][y]) { count++; if (color == * allChess[x+2][y]) { count++; if (color == allChess[x+3][y]) { * count++; } } } */ // 通过循环来做棋子相连的判断 /* * int i = 1; while (color == allChess[x + i][y + 0]) { count++; i++; } * i = 1; while (color == allChess[x - i][y - 0]) { count++; i++; } if * (count >= 5) { flag = true; } // 纵向的判断 int i2 = 1 ; int count2 = 1 ; * while (color == allChess[x + 0][y + i2]) { count2++; i2++; } i2 = 1; * while (color == allChess[x - 0][y - i2]) { count2++; i2++; } if * (count2 >= 5) { flag = true ; } // 斜方向的判断(右上 + 左下) int i3 = 1 ; int * count3 = 1 ; while (color == allChess[x + i3][y - i3]) { count3++; * i3++; } i3 = 1; while (color == allChess[x - i3][y + i3]) { count3++; * i3++; } if (count3 >= 5) { flag = true ; } // 斜方向的判断(右下 + 左上) int i4 = * 1 ; int count4 = 1 ; while (color == allChess[x + i4][y + i4]) { * count4++; i4++; } i4 = 1; while (color == allChess[x - i4][y - i4]) { * count4++; i4++; } if (count4 >= 5) { flag = true ; } */ 调用ActiveX后,怎么不让刷新页面 问一下反射机制 问个输出的问题 关于JfreeChart制作时序图表 关于java.io 类 PrintWriter 如何取到当前url页面的全部内容,在线等... 请大家说说interface的用法 打印分页,预览怎样才能实现呀! 快来帮帮忙!一个jni问题。 鸭子也要飞 开源拼写检查项目--jortho 一个基础问题,但就是搞不懂~~摆脱大家帮帮忙~
// 保存共有相同颜色多少棋子相连
int count = 1;
// 判断横向是否有5个棋子相连,特点 纵坐标 是相同, 即allChess[x][y]中y值是相同
int color = allChess[x][y];
/*
* if (color == allChess[x+1][y]) { count++; if (color ==
* allChess[x+2][y]) { count++; if (color == allChess[x+3][y]) {
* count++; } } }
*/
// 通过循环来做棋子相连的判断
/*
* int i = 1; while (color == allChess[x + i][y + 0]) { count++; i++; }
* i = 1; while (color == allChess[x - i][y - 0]) { count++; i++; } if
* (count >= 5) { flag = true; } // 纵向的判断 int i2 = 1 ; int count2 = 1 ;
* while (color == allChess[x + 0][y + i2]) { count2++; i2++; } i2 = 1;
* while (color == allChess[x - 0][y - i2]) { count2++; i2++; } if
* (count2 >= 5) { flag = true ; } // 斜方向的判断(右上 + 左下) int i3 = 1 ; int
* count3 = 1 ; while (color == allChess[x + i3][y - i3]) { count3++;
* i3++; } i3 = 1; while (color == allChess[x - i3][y + i3]) { count3++;
* i3++; } if (count3 >= 5) { flag = true ; } // 斜方向的判断(右下 + 左上) int i4 =
* 1 ; int count4 = 1 ; while (color == allChess[x + i4][y + i4]) {
* count4++; i4++; } i4 = 1; while (color == allChess[x - i4][y - i4]) {
* count4++; i4++; } if (count4 >= 5) { flag = true ; }
*/