Ejemplo n.º 1
0
 public FastConsoleWriter(FastConsole fastConsole, List<FastConsoleRow> rows)
 {
     Line = 0;
     this.rows = rows ?? new List<FastConsoleRow>();
     ResetColor();
     this.fastConsole = fastConsole;
 }
Ejemplo n.º 2
0
 public static void ShowProblems()
 {
     var console = new FastConsole();
     var p = 0;
     while(true)
     {
         var problem = ProblemsSet.GetProblem(p);
         var game = new Game(problem, new Output() { solution = "" }, new string[0]);
         var map = game.map;
         using (var drawer = new Drawer(console))
         {
             drawer.console.WriteLine(string.Format("problem {0}", p));
             drawer.DrawMap(map, null);
             foreach (var unit in game.problem.units)
             {
                 drawer.DrawUnit(unit);
             }
         }
         Console.SetWindowPosition(0, 0);
         var key = Console.ReadKey(false);
         if (key.Key == ConsoleKey.LeftArrow)
             --p;
         else
             ++p;
         if (p < 0)
             p = 0;
         if (p > 24)
             p = 24;
     }
 }
Ejemplo n.º 3
0
 public static void DebugSolve(int problemnum, int seed, string[] magicSpells, int delay)
 {
     var problem = ProblemsSet.GetProblem(problemnum);
     //var problemSolver = new MagicProblemSolver();
     //var solver = new MuggleProblemSolver();
     var solver = new MuggleProblemSolver_MultiUnit(1);
     var fastConsole = new FastConsole();
     solver.SolutionAdded += (g, s) =>
     {
         using (var drawer = new Drawer(fastConsole))
         {
             drawer.DrawMap(g.map, g.currentUnit);
             drawer.console.WriteLine("Score: " + g.CurrentScore);
         }
         Console.ReadKey(true);
         var unit = g.currentUnit;
         foreach (var c in s.Where(x => !MoveTypeExt.IsIgnored(x)))
         {
             var moveType = MoveTypeExt.Convert(c);
             if (!moveType.HasValue)
                 throw new InvalidOperationException(string.Format("Invalid char in solution: {0}. Char: '{1}'", s, c));
             var newUnit = unit.Move(moveType.Value);
             using (var drawer = new Drawer(fastConsole))
             {
                 if (newUnit.IsCorrect(g.map))
                     drawer.DrawMap(g.map, newUnit);
                 else
                     drawer.DrawMap(g.map, unit, locked: true);
                 drawer.console.WriteLine("Score: " + g.CurrentScore);
                 unit = newUnit;
             }
             Thread.Sleep(delay < 0 ? 0 : delay);
         }
         Console.ReadKey(true);
     };
     solver.Solve(problem, problem.sourceSeeds[seed], magicSpells);
     while (Console.ReadKey(true).Key != ConsoleKey.Escape)
     { }
 }
Ejemplo n.º 4
0
 public void Run()
 {
     var console = new FastConsole();
     while (game.state == GameBase.State.UnitInGame || game.state == GameBase.State.WaitUnit)
     {
         using (var drawer = new Drawer(console))
         {
             Console.SetWindowPosition(0, 0);
             //drawer.console.WriteLine("Score=" + game.CurrentScore);
             drawer.DrawMap(game.map, game.currentUnit);
             drawer.console.WriteLine("Score=" + game.CurrentScore);
         }
         Console.SetWindowPosition(0, 0);
         if (delay > 0) Thread.Sleep(delay);
         else if (delay < 0)
         {
             var key = Console.ReadKey(false);
             if (key.Key == ConsoleKey.Z && key.Modifiers.HasFlag(ConsoleModifiers.Control))
                 if (key.Modifiers.HasFlag(ConsoleModifiers.Shift)) game.StepBack(-10);
                 else game.StepBack(-2);
             else if (key.Key == ConsoleKey.Escape) break;
         }
         game.Step();
     //                Console.SetCursorPosition(0, 40);
     //                Console.Write(new string(Enumerable.Range(0, 500).Select(_ => ' ').ToArray()));
     //                Console.SetCursorPosition(0, 40);
     //                Console.Write(game.enteredString.ToString());
     }
     Console.SetCursorPosition(0, game.map.Height * 3 + 5);
     Console.Write("GAME OVER");
     Console.WriteLine(game.state);
     Console.WriteLine("Score="+game.CurrentScore);
     Console.WriteLine("PowerWords="+string.Join(",", game.EnteredMagicSpells));
     Console.WriteLine("String=" + game.enteredString);
     Console.ReadKey();
 }