Пример #1
0
        public async Task <IEnumerable <Position> > GetDeadPositions(Fuego fuego)
        {
            var action = FuegoAction.ThatReturnsGtpResponse(() =>
            {
                // Set the player's strength
                if (_lastMaxGames != fuego.MaxGames)
                {
                    SendCommand("uct_param_player max_games " + fuego.MaxGames);
                    _lastMaxGames = fuego.MaxGames;
                }
                var result = SendCommand("final_status_list dead");
                return(result);
            });

            EnqueueAction(action);
            var response = await action.GetGtpResponseAsync();

            var positions = response.Text.Split(new[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            var mark      = new List <Position>();

            foreach (string position in positions)
            {
                mark.Add(Position.FromIgsCoordinates(position));
            }
            return(mark);
        }
Пример #2
0
        public async Task <IEnumerable <Position> > GetIsolatedDeadPositions(Fuego fuego, GameController gameController)
        {
            var action = FuegoAction.ThatReturnsGtpResponse(() =>
            {
                var information = new AiGameInformation(gameController.Info, StoneColor.Black,
                                                        gameController.Players.Black, gameController.GameTree);
                TrueInitialize(information);
                FixHistory(information);
                // Set the player's strength
                if (_lastMaxGames != fuego.MaxGames)
                {
                    SendCommand("uct_param_player max_games " + fuego.MaxGames);
                    _lastMaxGames = fuego.MaxGames;
                }
                var result = SendCommand("final_status_list dead");
                return(result);
            });

            EnqueueAction(action);
            var response = await action.GetGtpResponseAsync();

            var positions = response.Text.Split(new[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            var mark      = new List <Position>();

            foreach (string position in positions)
            {
                mark.Add(Position.FromIgsCoordinates(position));
            }
            return(mark);
        }
Пример #3
0
        public AIDecision RequestMove(Fuego fuego, AiGameInformation gameInformation)
        {
            var action = FuegoAction.ThatReturnsAiDecision(() => TrueRequestMove(fuego, gameInformation));

            EnqueueAction(action);
            return(action.GetAiDecisionResult());
        }
Пример #4
0
        /// <summary>
        /// Called once, at the start of omegaGo, just after Fuego registration, this creates the Fuego engine and associates it
        /// with this instance. That may take a long time so it's put in the Fuego queue as its first item. Called from the UI thread.
        /// </summary>
        public void AppWideInitialization()
        {
            var init = new FuegoAction(() =>
            {
                _engine = AISystems.FuegoBuilder.CreateEngine(0);
            });

            EnqueueAction(init);
        }
Пример #5
0
        public void MovePerformed(AiGameInformation aiGameInformation)
        {
            var action = new FuegoAction(() =>
            {
                FixHistory(aiGameInformation);
            });

            EnqueueAction(action);
        }
Пример #6
0
        /// <summary>
        /// Schedules the initialization of Fuego for a game.
        /// </summary>
        public void Initialize(AiGameInformation gameInformation)
        {
            var init = new FuegoAction(() =>
            {
                TrueInitialize(gameInformation);
            });

            EnqueueAction(init);
        }
Пример #7
0
        public AIDecision GetIsolatedHint(Fuego fuego, AiGameInformation gameInformation)
        {
            var action = FuegoAction.ThatReturnsAiDecision(() =>
            {
                TrueInitialize(gameInformation);
                return(TrueRequestMove(fuego, gameInformation));
            });

            EnqueueAction(action);
            return(action.GetAiDecisionResult());
        }
Пример #8
0
        public AIDecision GetHint(Fuego fuego, AiGameInformation gameInformation)
        {
            var action = FuegoAction.ThatReturnsAiDecision(() =>
            {
                var result = TrueRequestMove(fuego, gameInformation);
                UndoOneMove();
                return(result);
            });

            EnqueueAction(action);
            return(action.GetAiDecisionResult());
        }
Пример #9
0
 /// <summary>
 /// Schedules a block of code to run on a different thread when possible. Only code passed to this method
 /// may call <see cref="IGtpEngine.SendCommand(string)"/>, no other code may do that. This prevents Fuego from being
 /// called from multiple threads at the same time. Never add actions to the queue directly, always use this method.
 /// </summary>
 /// <param name="action">The action.</param>
 private void EnqueueAction(FuegoAction action)
 {
     _queue.Enqueue(action);
     ExecuteQueueIfNotRunning();
 }
Пример #10
0
        public void MoveUndone()
        {
            var action = new FuegoAction(UndoOneMove);

            EnqueueAction(action);
        }