From e584e3a9193de4d035f786f2e304888ea3266748 Mon Sep 17 00:00:00 2001 From: Malte Tammena Date: Wed, 18 Oct 2017 23:35:26 +0200 Subject: [PATCH] Moved the method --- src/game/Game.java | 83 ++++++++++++++++++++++++++++- src/player/maurizio/MaurizioAI.java | 77 -------------------------- 2 files changed, 81 insertions(+), 79 deletions(-) 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