@@ -76,6 +76,9 @@ public static Coordinate findWin(int[][] in) {
76
76
}
77
77
78
78
// row, col 代表我们现在正在扫描的点的坐标
79
+ // side 记录目前是哪一方的棋子
80
+ // direction 记录扫描方向,有四个方向扫描:右,右下,左下,下。
81
+ // num: 代表扫描到第几个棋子了。
79
82
public static Coordinate findWinHelp (int [][]in ,int col ,int row ,int side ,int direction ,Visit [][]visit ,int num ) {
80
83
// 扫描不可以超过范围
81
84
if (col >=in .length ||row >=in .length ||row <0 ||col <0 ) {
@@ -87,6 +90,7 @@ public static Coordinate findWinHelp(int[][] in, int col, int row, int side, int
87
90
return null ;
88
91
}
89
92
93
+ // 必须是同边的棋子。例如,都是1,或都是2.
90
94
if (side !=in [row ][col ]) {
91
95
return null ;
92
96
}
@@ -96,10 +100,12 @@ public static Coordinate findWinHelp(int[][] in, int col, int row, int side, int
96
100
return new Coordinate (col ,row );
97
101
}
98
102
103
+ // 如果未设置标记,新建标记。
99
104
if (visit [row ][col ] ==null ) {
100
105
visit [row ][col ] =new Visit (false ,false ,false ,false );
101
106
}
102
107
108
+ // 对各个方向进行不同的搜索方向。
103
109
if (direction ==0 ) {
104
110
if (visit [row ][col ].right ) {
105
111
return null ;