private static void PlayManual(IGenerator rnd) { var game = Game.Create(rnd); while (game.IsActive) { Console.Clear(); Console.WriteLine(game.Formatted()); var key = Console.ReadKey(); Move move = Move.Right; switch (key.Key) { case ConsoleKey.LeftArrow: move = Move.Left; break; case ConsoleKey.RightArrow: move = Move.Right; break; case ConsoleKey.DownArrow: move = Move.Down; break; case ConsoleKey.UpArrow: move = Move.Up; break; } game.Move(move, rnd); } Console.Clear(); Console.Write(game.Formatted()); Console.WriteLine(); Console.WriteLine("Done"); }
private static void Play(IGenerator rnd, ISolver solver, TimeSpan movetime, int runs, bool showGames, string logfile) { var running = new RunCollection(); Console.Clear(); for (int i = 1; i <= runs; i++) { if (!showGames) { Console.Write("\r{0}", i); } var game = Game.Create(rnd); while (game.IsActive) { if (showGames) { Console.Clear(); Console.WriteLine(game.Formatted()); } var result = solver.Move(game.Current, movetime); if (result.NoResult) { break; } else { game.Move(result.Move, rnd); } } running.Apply(game.Current); if (showGames) { Console.Clear(); Console.Write(game.Formatted()); Console.WriteLine(); } } Console.WriteLine(); running.Save(logfile); running.Save(Console.Out); Console.WriteLine("Done"); }