/// <summary> /// Updates the board visually according to the logicBoard state /// </summary> /// <param name="c">The column number of thhe move (0..7)</param> /// <param name="r">The row number of the move (0..7)</param> private void PlayMove(int c, int r) { var playable = logicBoard.IsPlayable(c, r, playerTurn % 2 != 0); if (playable) { logicBoard.PlayMove(c, r, playerTurn % 2 != 0); loadFromLogicBoard(); if (playerTurn % 2 == 0) { whitePlayer.start(); blackPlayer.stop(); } else { blackPlayer.start(); whitePlayer.stop(); } playerTurn++; if (!CanPlayerPlay(playerTurn) && !IsGameFinished()) { playerTurn++; string color = (playerTurn % 2 != 0) ? "white" : "black"; Console.WriteLine($"{color} cannot play this turn"); } Console.WriteLine($" player turn is {playerTurn}"); NotifyPropertyChanged("BlackScore"); NotifyPropertyChanged("WhiteScore"); NotifyPropertyChanged("CurrentTurn"); } }
public double eval() { double mobility = 0; int maxCoin = 0;//Les pions les plus présents->devient le maxPlayer int minCoin = 0; int maxMobility = 0;//Regarde combien de mouvement sont possibles. int minMobility = 0; if (board.GetBlackScore() > board.GetWhiteScore())//Black est max { maxCoin = board.GetBlackScore(); minCoin = board.GetWhiteScore(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (board.IsPlayable(i, j, false))//On regarde les noirs { maxMobility++; } else if (board.IsPlayable(i, j, true)) { minMobility++; } } } } else { maxCoin = board.GetWhiteScore(); minCoin = board.GetBlackScore(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (board.IsPlayable(i, j, false))//On regarde les noirs { minMobility++; } else if (board.IsPlayable(i, j, true)) { maxMobility++; } } } } //Parity double parity = 100 * (maxCoin - minCoin) / (maxCoin - minCoin); //Mobility if (maxMobility + minMobility != 0) { mobility = 100 * (maxMobility - minMobility) / (maxMobility + minMobility); } else { mobility = 0; } //Corners captured //Stability //Score from : https://github.com/kartikkukreja/blog-codes/blob/master/src/Heuristic%20Function%20for%20Reversi%20(Othello).cpp double score = (10 * parity) + (78.922 * mobility); return(score); }