Java ursive函数,在这一点上,除此之外的所有内容都被短路,因此每个递归依次将求值为true(如果存在连接)。非常感谢你。我已经盯着它看了好几个小时了!! public boolean checkWin() { // check horizontal
ursive函数,在这一点上,除此之外的所有内容都被短路,因此每个递归依次将求值为true(如果存在连接)。非常感谢你。我已经盯着它看了好几个小时了!!Java ursive函数,在这一点上,除此之外的所有内容都被短路,因此每个递归依次将求值为true(如果存在连接)。非常感谢你。我已经盯着它看了好几个小时了!! public boolean checkWin() { // check horizontal,java,recursion,control-flow,Java,Recursion,Control Flow,ursive函数,在这一点上,除此之外的所有内容都被短路,因此每个递归依次将求值为true(如果存在连接)。非常感谢你。我已经盯着它看了好几个小时了!! public boolean checkWin() { // check horizontal for (int x = 0; x < BOARD_WIDTH; x++) { if (recursiveCheck(4, x, 0, 1, 0)) { return true; }
public boolean checkWin() {
// check horizontal
for (int x = 0; x < BOARD_WIDTH; x++) {
if (recursiveCheck(4, x, 0, 1, 0)) {
return true;
}
}
return false;
}
private boolean recursiveCheck(int count, int x, int y, int incX, int incY) {
while (count > 1) {
if (x + incX < BOARD_WIDTH && y + incY < BOARD_HEIGHT && board[x][y] != 0
&& board[x][y] == board[x + incX][y + incY]) {
System.out.println("TRUE");
System.out.printf("x = %d, x+1 = %d", x, x + incX);
recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
}
return false;
}
System.out.println("BIG TRUE");
return true;
}
private boolean recursiveCheck(int count, int x, int y, int incX, int incY) {
while (count > 1) {
if ((x + incX < BOARD_WIDTH && y + incY < BOARD_HEIGHT && board[x][y] != 0
&& board[x][y] == board[x + incX][y + incY]) {
recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
}
return false;
}
return true;
}
recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
return recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
public boolean checkWin() {
// check horizontal
for (int x = 0; x < BOARD_WIDTH; x++) {
if (recursiveCheck(4, x, 0, 1, 0)) {
System.out.println("SMALL TRUE");
return true;
}
}
System.out.println("SMALL FALSE");
return false;
}
private boolean recursiveCheck(int count, int x, int y, int incX, int incY) {
while (count > 1) {
if (x + incX < BOARD_WIDTH && y + incY < BOARD_HEIGHT && board[x][y] != 0
&& board[x][y] == board[x + incX][y + incY]) {
System.out.println("TRUE");
System.out.printf("x = %d, x+1 = %d", x, x + incX);
recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
}
System.out.println("BIG FALSE");
return false;
}
System.out.println("BIG TRUE");
return true;
}
public boolean checkWin() {
// check horizontal
int[][] cartesian = { { 0, 1 }, { 1, 1 }, { 1, 0 }, { 1, -1 } };
for (int[] c : cartesian) {
for (int x = 0; x < BOARD_WIDTH; x++) {
for (int y = 0; y < BOARD_HEIGHT; y++) {
if (recursiveCheck(Game.connect, x, y, c[0], c[1])) {
return true;
}
}
}
}
return false;
}
private boolean recursiveCheck(int count, int x, int y, int incX, int incY) {
while (count - 1 > 0) {
if (x + incX < BOARD_WIDTH && x + incX > 0 && y + incY < BOARD_HEIGHT && y + incY > 0 && board[x][y] != 0
&& board[x][y] == board[x + incX][y + incY]) {
return recursiveCheck(count - 1, x + incX, y + incY, incX, incY);
}
return false;
}
return true;
}