// STATIC EVALUATION FUNCTION public int EvalCurrentBoard(GameBoard <counters> board, GameBoard <int> scoreBoard, int ourindex, counters us) { // score decs int score = 10; int two_score = 10; int one_score = 10; // assign score = EvalForWin(board, ourindex, us); // 1 for win, 0 for unknown // assign two score if (FindTwoInARow(board, us)) // player win? { score = 100; // twoinrow confirmed } two_score = 100; if (FindTwoInARow(board, us + 1)) // twoinrow opponent? { score = -100; // twoinrow confirmed } two_score = -100; // one score if (FindOneInARow(board, ourindex, us)) // oneinrow? { score = 10; // oneinrow confirmed } one_score = 10; if (FindOneInARow(board, ourindex, us + 1)) // oneinarow opponent? { score = -10; // oneinrow confirmed } one_score = -10; // ************************************************************************************************ // ************************************************************************************************ // ******** ASSIGN MORE WEIGHT TO INDIVIDUAL CELLS WITH MORE PROMINENT POSITIONING TO BUILD ON **** // ************************************************************************************************ // ************************************************************************************************ // assign more weight to score with individual cell moves with prominent positioning if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[4, 4] = counter; if (board[4, 4] == counter) { return(score = 125); // player win confirmed } return(score = 10); } // assign more weight to score with individual cell moves with prominent positioning if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[4, 4] = counter; if (board[4, 4] == counter) { // assign score to correct cell in score scoreBoard[4, 4] = score; return(score = 125); // player win confirmed } return(score = 10); } else if (board.IsMiddleEmpty() == true & FindTwoInARow(board, us + 1)) { score = -100; // player win? board[4, 4] = counter; if (board[4, 4] == counter) { // assign score to correct cell in score scoreBoard[4, 4] = score; return(score = -125); // opponent win confirmed } return(score = 10); } if (board.IsTopLeftEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[1, 1] = counter; if (board[1, 1] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[1, 1] = score; return(score = 115); // player win confirmed } return(score = 10); } else if (board.IsTopLeftEmpty() == true & FindTwoInARow(board, us + 1)) { score = -100; // player win? board[1, 1] = counter; if (board[1, 1] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[1, 1] = score; return(score = -115); // opponent win confirmed } return(score = 10); } if (board.IsTopRightEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[7, 1] = counter; if (board[7, 1] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[7, 1] = score; return(score = 115); // player win confirmed } return(score = 10); } else if (board.IsTopRightEmpty() == true & FindTwoInARow(board, us + 1)) { score = -100; // player win? board[7, 1] = counter; if (board[7, 1] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[7, 1] = score; return(score = -115); // opponent win confirmed } return(score = 10); } if (board.IsBottomLeftEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[1, 7] = counter; if (board[1, 7] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[1, 7] = score; return(score = 115); // player win confirmed } return(score = 10); } else if (board.IsBottomLeftEmpty() == true & FindTwoInARow(board, us + 1)) { score = -100; // player win? board[1, 7] = counter; if (board[1, 7] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[1, 7] = score; return(score = -115); // opponent win confirmed } return(score = 10); } if (board.IsBottomRightEmpty() == true & FindTwoInARow(board, us)) { score = 100; // player win? board[7, 7] = counter; if (board[7, 7] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[7, 7] = score; return(score = 115); } return(score = 10); } else if (board.IsBottomRightEmpty() == true & FindTwoInARow(board, us + 1)) { two_score = -100; // player win? board[7, 7] = counter; if (board[7, 7] == counters.EMPTY) { // assign score to correct cell in score scoreBoard[7, 7] = score; return(score = -115); // opponent win confirmed } } // ************************************************************************************************ // ************************************************************************************************ // ** END OF ASSIGN MORE WEIGHT TO INDIVIDUAL CELLS WITH MORE PROMINENT POSITIONING TO BUILD ON ** // ************************************************************************************************ // ************************************************************************************************ // ************************************************************************************************ // ************************************************************************************************ // ************************* ASSIGNING LESSER VALUE TO EDGES *********************************** // ************************************************************************************************ // ************************************************************************************************ // ************************************************************************************************ // ************************************************************************************************ // ************************* END OF ASSIGNING LESSER VALUE TO EDGES ******************************* // ************************************************************************************************ // ************************************************************************************************ /* // if one in a row, if two in a row found, three in a row found etc.... * if (score == -1000 || score == 1000) * { * board.DisplayBoard(); * // Console.Write("three: " + score); * // Console.ReadLine(); * * return score * Consts.MAX_SCORE; * } */ if (two_score != 0) { // board.DisplayBoard(); // Console.Write("two: " + two_score); //Console.ReadLine(); return(two_score); } if (one_score != 0) { //board.DisplayBoard(); // Console.Write("one: " + one_score); return(one_score); } else { return(score = 10); } }