示例#1
0
        private int GetChildRank(MiniMaxContext miniMaxContext, IBoard board, IPlayer minimizePlayer)
        {
            var context = new MiniMaxContext {
                Board           = board,
                CurrentPlayer   = miniMaxContext.CurrentPlayer,
                Opponent        = miniMaxContext.Opponent,
                MinimizedPlayer = minimizePlayer,
                Players         = miniMaxContext.Players
            };

            return(DetermineBest(context).Rank);
        }
示例#2
0
 private static int GetRank(IPlayer winner, MiniMaxContext content)
 {
     if (winner is Nobody)
     {
         return(0);
     }
     if (winner.Symbol == content.CurrentPlayer.Symbol)
     {
         return(-10);
     }
     if (winner.Symbol == content.Opponent.Symbol)
     {
         return(10);
     }
     throw new ArgumentException();
 }
示例#3
0
 private IPlayer GetOpponent(MiniMaxContext context)
 {
     return(context.Players.First(p => p.Symbol != context.MinimizedPlayer.Symbol));
 }