so i've been trying to get the checkWin method for an bot to use, BUT the win condition wont trigger no matter what
public boolean checkWinner(int player) {
int[] lineX = { 1, 1, 1,1};
//int[] lineX = { 1, 1, 1 };
int[] lineY = { 0, 1, 1 ,-1};
for (int x = 0; x < 19; x++) {
for (int y = 0; y < 19; y++) {
if (this.cell[x][y] == player)
for (int i = 0; i <4; i++) {
int count = 1;
for (int j = 1; j <=4; ) {
int vtx = x + lineX[i] * j;
// vector x = x + lineX * J (loop) | horizontal
int vty = y + lineY[i] * j;
System.out.println(" x: "+x);
System.out.println(" y: "+y);
if (vtx >= 0 && vty >= 0 && vtx < 19 && vty < 19 &&
this.cell[vtx][vty] == player) {
count++;
j++;
System.out.println("count: "+count);
System.out.println("j: "+j);
}
break;
}
if (count == 5)
return true;
}
}
}
return false;
}
any thoughts?
i've tried to change the size and value of the array, loop count, but the count wont go above 2 hence no one is winningenter image description here