public DelegateBasedAi(MoveChooser chooser)
 {
     // still an object
     // cant instantiate it, but can construct value that will fit into it
     // through static method or lambda expression
     // reflection
     chooser.GetMethodInfo();
     chooserField = chooser;
     // Progress += chooserField; wrong type
     // every time the progress event gets fired, this function will run with augements provided
     Progress += (a, b, c) => { Console.WriteLine("Some action!"); };
 }
示例#2
0
        static void Main()
        {
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    IKnightMover          knightMover          = new KnightMover();
                    IChessboardService    chessboardService    = new ChessboardService();
                    IAccessibilityService accessibilityService = new AccessibilityService();
                    IMoveChooser          moveChooser          = new MoveChooser(accessibilityService);
                    IGameController       gameController       = new GameController(accessibilityService, chessboardService, moveChooser, knightMover);

                    bool isGameWon = gameController.PlayGame(new Point(i, j), isEnabledWaitForUserInput: false);
                    if (!isGameWon)
                    {
                        throw new Exception($"Lost game at starting point ({i}, {j})");
                    }
                }
            }

            Console.Clear();
            Console.WriteLine("Game is won from all starting points, good job!");
        }
示例#3
0
 public DelegateBasedAi(MoveChooser chooser)
 {
     _chooser = chooser;
 }
示例#4
0
 void Awake()
 {
     moveChooser = GetComponentInChildren <MoveChooser>();
 }