private static bool IsTerminalState(Piece[][][] board) { Match[] matches = BoardChecker.FindMatches(board); int p1Score = matches.Where(match => match.playerNum == 1).Count(); int p2Score = matches.Where(match => match.playerNum == 2).Count(); return(p1Score == 3 || p2Score == 3); }
private static int GetBoardValue(Piece[][][] board) { Match[] matches = BoardChecker.FindMatches(board); int p1value = matches.Where(match => match.playerNum == 1).Count() * 3; int p2value = matches.Where(match => match.playerNum == 2).Count() * 3; p2value = p2value == 9 ? 100 : p2value; p1value = p1value == 9 ? 100 : p1value; return(p1value - p2value); }
public void CheckMatches(int playerNum) { Piece[][][] b = BoardStateUtils.GenerateBoardState(_moves); Match[] matches = BoardChecker.FindMatches(b); Messenger <Match[]> .Broadcast(GameEvent.PIECES_MATCHED, matches); Match[] currentPlayerMatches = matches.Where(match => match.playerNum == playerNum).ToArray(); if (currentPlayerMatches.Length == 3) { Debug.Log("All Pieces Matched!"); gameOver = true; Messenger <int> .Broadcast(GameEvent.GAME_OVER, playerNum); } }