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!"); }; }
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!"); }
public DelegateBasedAi(MoveChooser chooser) { _chooser = chooser; }
void Awake() { moveChooser = GetComponentInChildren <MoveChooser>(); }