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); }
private Knowledge(BoardTO boardState, Move move, Symbol symbol, int numExperiences, double totalValue) { BoardState = boardState; Move = move; Symbol = symbol; this.numExperiences = numExperiences; this.totalValue = totalValue; }
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("---------"); }
public OnStartEventArgs(BoardTO boardState) { BoardState = boardState; }
public OnWinEventArgs(BoardTO boardState, Move move, Player player) { BoardState = boardState; Move = move; Player = player; }
public Experience(BoardTO boardState, Move move, Symbol symbol) { BoardState = boardState; Move = move; Symbol = symbol; }