Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            if (args.Length == 0)
            {
                Console.BackgroundColor = ConsoleColor.Blue;

                Console.Clear();
                TetrisOptions.PlayGame();

                return;
            }
            else if (args[0] == "-solve")
            {
                SolveTetris.Solve(int.Parse(args[1]));
                return;
            }
            else if (args[0] == "-replay")
            {
                Console.BackgroundColor = ConsoleColor.Black;
                Console.Clear();
                TetrisOptions.Replay(args[1]);
                return;
            }
            else
            {
                Console.WriteLine("Usage: \ntetris\ntetris -solve max-depth\ntetris -replay \"script\"");
            }
        }
Ejemplo n.º 2
0
 static void Solve(Vec256 board, Vec256 piece, int step, int score)
 {
     while ((board & (piece << TetrisOptions.width)) == 0)
     {
         piece <<= TetrisOptions.width;
     }
     board |= piece;
     TetrisOptions.RemoveFullLines(ref board, ref score);
     if (score > maxScoreFound)
     {
         maxScoreFound = score;
         Console.WriteLine($"new max score={maxScoreFound} at depth {maxStepFound} after processing {processedMoves:N0} moves at {timer.Elapsed}");
         Console.WriteLine($"  {GetMovesAsString()}");
     }
     Solve(board, step + 1, score);
 }