public static void Main() { for (var i = 1; i < Depth; i++) { Console.WriteLine($"\nDepth: {i}\n"); var board = BoardBuilder.Build(); var engine = new ChessEngine(board, i); var stopwatch = Stopwatch.StartNew(); engine.GetMove(Side.White); stopwatch.Stop(); Console.WriteLine($"Elapsed: {stopwatch.ElapsedMilliseconds / 1000.0}"); for (var k = 0; k < i; k++) { var max = engine.Depths[k].Max(m => m.TotalValue); var count = engine.Depths[k].Count(m => m.TotalValue == max); Console.WriteLine($"Depth {k}, Max Score {max}, Count of Max Score Nodes {count}, Total Nodes: {engine.Depths[k].Count}"); } } if (Debugger.IsAttached) { Console.ReadLine(); } }
public void Total_moves_at_each_depth_is_correct() { _engine.GetMove(Side.White); for (var i = 0; i < Depth; i++) { var max = _engine.Depths[i].Max(m => m.TotalValue); var count = _engine.Depths[i].Count(m => m.TotalValue == max); Console.WriteLine($"Depth {i}, Max Score {max}, Count of Max Score Nodes {count}, Total Nodes: {_engine.Depths[i].Count}"); } }
public void Play() { _board = BoardBuilder.Build(); _engine = new ChessEngine(_board, 5); Title = "Chess"; OutputEncoding = Encoding.Unicode; BackgroundColor = ConsoleColor.Black; ForegroundColor = ConsoleColor.White; Clear(); var side = Side.White; while (true) { DisplayBoard(); ForegroundColor = ConsoleColor.White; Write("\nPress ENTER."); ReadLine(); var move = _engine.GetMove(side); GC.Collect(); var piece = _board.Squares[move.FromPosition.Row, move.FromPosition.Column]; _board.Squares[move.ToPosition.Row, move.ToPosition.Column] = piece; _board.Squares[move.FromPosition.Row, move.FromPosition.Column] = null; Clear(); side = (Side)(-(int)side); } // ReSharper disable once FunctionNeverReturns }