Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            // ////////////////////////////////////////////////////////////// //
            // Create an instance of our Ultron thinker via ThinkerPrototype. //
            // If we created directly with new, it would not be properly      //
            // configured.                                                    //
            // ////////////////////////////////////////////////////////////// //

            // Create a configuration for a default ColorShapeLinks match
            MatchConfig mc = new MatchConfig();

            // Get the fully qualified name of our basic Ultron thinker
            string ultronFullName = typeof(UltronThinker).FullName;

            // Create a prototype for our thinker
            ThinkerPrototype tp = new ThinkerPrototype(ultronFullName, "", mc);

            // Create an instance of our basic Ultron thinker
            IThinker ultronThinker = tp.Create();

            // //////////////////////////////////////////////////////// //
            // Create a board so we can test how our thinker will play. //
            // //////////////////////////////////////////////////////// //

            // A cancellation token, will be ignored
            CancellationToken ct = new CancellationToken();

            // Create a ColorShapeLinks board with default size
            Board board = new Board();

            // Show initial board
            Console.WriteLine("\n=== Initial board ===\n");
            ShowBoard(board);

            // Make some moves manually
            board.DoMove(PShape.Round, 0);  // White plays round piece in col 0
            board.DoMove(PShape.Square, 4); // Red plays square piece in col 4
            board.DoMove(PShape.Square, 5); // White plays round piece in col 5

            // Show board after our three manual moves
            Console.WriteLine("\n=== Board after three manual moves ===\n");
            ShowBoard(board);

            // What move would Ultron make at this moment?
            FutureMove ultronMove = ultronThinker.Think(board, ct);

            // Show move
            Console.WriteLine($"-> Ultron will play {ultronMove}");

            // Make the move selected by Ultron
            board.DoMove(ultronMove.shape, ultronMove.column);

            // Show board after Ultron made its move
            Console.WriteLine("\n=== Board after Ultron made move ===\n");
            ShowBoard(board);
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     MatchConfig      mc      = new MatchConfig(); // Use default values
     ThinkerPrototype tp      = new ThinkerPrototype(typeof(MyThinker).FullName, "", mc);
     IThinker         thinker = tp.Create();
 }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            // ////////////////////////////////////////////////////////////// //
            // Create an instance of our Oizys thinker via ThinkerPrototype. //
            // If we created directly with new, it would not be properly      //
            // configured.                                                    //
            // ////////////////////////////////////////////////////////////// //

            // Create a configuration for a default ColorShapeLinks match
            MatchConfig mc = new MatchConfig();

            // Get the fully qualified name of our basic Oizys thinker
            string oizysFullName = typeof(OizysThinker).FullName;

            // Create a prototype for our thinker
            ThinkerPrototype tp = new ThinkerPrototype(oizysFullName, "", mc);

            // Create an instance of our basic Oizys thinker
            IThinker oizysThinker = tp.Create();

            // //////////////////////////////////////////////////////// //
            // Create a board so we can test how our thinker will play. //
            // //////////////////////////////////////////////////////// //

            // A cancellation token, will be ignored
            CancellationToken ct = new CancellationToken();

            // Create a ColorShapeLinks board with default size
            Board board = new Board();

            // Show initial board
            Console.WriteLine("\n=== Initial board ===\n");
            ShowBoard(board);

            // Make some moves manually
            board.DoMove(PShape.Round, 3);  // White plays (Round,col 3)
            board.DoMove(PShape.Square, 3); // Red   plays (Square,col 3)
            board.DoMove(PShape.Round, 2);  // White plays (Round,col 2)
            // board.DoMove(PShape.Square, 3); // Red   plays (Square,col 3)
            // board.DoMove(PShape.Round, 1);  // White plays (Round,col 1)
            // board.DoMove(PShape.Square, 3); // Red   plays (Square,col 3)
            // board.DoMove(PShape.Round, 3); // White plays (Round,col 3)

            // Show board after our three manual moves
            Console.WriteLine("\n=== Board after three manual moves ===\n");
            ShowBoard(board);

            // Starts timer
            DateTime startTime = DateTime.Now;

            // What move would Oizys make at this moment?
            FutureMove oizysMove = oizysThinker.Think(board, ct);

            // Show move and time
            Console.WriteLine(string.Format(
                                  "-> Oizys will play {0} after {1} ms.",
                                  oizysMove, (DateTime.Now - startTime).TotalMilliseconds));

            // Make the move selected by Oizys
            board.DoMove(oizysMove.shape, oizysMove.column);

            // Show board after Oizys made its move
            Console.WriteLine("\n=== Board after Oizys made move ===\n");
            ShowBoard(board);
        }