Esempio n. 1
0
        public Move GetBestMove(BoardTO boardState, Symbol symbol, IEnumerable <Move> validMoves)
        {
            var validMoveExperiences = validMoves.Select(vm => new Experience(boardState, vm, symbol));
            var knownMoves           = validMoveExperiences.Where(vm => knowledge.ContainsKey(vm));
            var unknownMoves         = validMoves.Except(knownMoves.Select(km => km.Move));

            return(unknownMoves.Any() ? unknownMoves.First() : knownMoves.Select(km => knowledge[km]).OrderByDescending(k => k.AverageValue).FirstOrDefault().Move);
        }
Esempio n. 2
0
        private Knowledge(BoardTO boardState, Move move, Symbol symbol, int numExperiences, double totalValue)
        {
            BoardState = boardState;
            Move       = move;
            Symbol     = symbol;

            this.numExperiences = numExperiences;
            this.totalValue     = totalValue;
        }
Esempio n. 3
0
 private void DisplayBoard(BoardTO board)
 {
     Console.WriteLine("---------");
     Console.WriteLine($"| {string.Join("|", board.Symbols.Take(3).Select(BoardDisplay))} |");
     Console.WriteLine("| ----- |");
     Console.WriteLine($"| {string.Join("|", board.Symbols.Skip(3).Take(3).Select(BoardDisplay))} |");
     Console.WriteLine("| ----- |");
     Console.WriteLine($"| {string.Join("|", board.Symbols.Skip(6).Take(3).Select(BoardDisplay))} |");
     Console.WriteLine("---------");
 }
Esempio n. 4
0
 public OnStartEventArgs(BoardTO boardState)
 {
     BoardState = boardState;
 }
Esempio n. 5
0
 public OnWinEventArgs(BoardTO boardState, Move move, Player player)
 {
     BoardState = boardState;
     Move       = move;
     Player     = player;
 }
Esempio n. 6
0
 public Experience(BoardTO boardState, Move move, Symbol symbol)
 {
     BoardState = boardState;
     Move       = move;
     Symbol     = symbol;
 }