diff --git a/src/game/Game.java b/src/game/Game.java index 6b84c57..d6da950 100644 --- a/src/game/Game.java +++ b/src/game/Game.java @@ -202,14 +202,14 @@ public class Game { * @return the state of the game, -1 = still undecided , 0 = draw, 1 = Player 1 wins, ... */ private int checkState(boolean output) { - if(MaurizioAI.checkWin(this.board, p1.getID())){ + if(checkWin(this.board, p1.getID())){ this.gameOn = false; if(output){ System.out.println(p1.getP().getName() + " wins!"); } return p1.getID(); // player 1 wins } - if(MaurizioAI.checkWin(this.board, p2.getID())){ + if(checkWin(this.board, p2.getID())){ this.gameOn = false; if(output){ System.out.println(p2.getP().getName() + " wins!"); @@ -276,4 +276,83 @@ public class Game { } System.out.println(); } + + public static boolean checkWin(int[][] board, int player){ + int winLength = 4; + boolean win = false; + // check columns for win + for(int i=0;i