Esempio n. 1
0
        /// <summary>
        /// Informs the AI engine that a move was just made. Stateful AIs (i.e. Fuego) use this.
        /// <para>
        /// This is called synchronously in the main thread by the game controller or the assistant.
        /// </para>
        /// </summary>
        /// <param name="move">The move.</param>
        /// <param name="gameTree">The game tree.</param>
        /// <param name="informedPlayer">The player who is associated with this AI, not the player who made the move.</param>
        /// <param name="info">Information about the game</param>
        public override void MovePerformed(Move move, GameTree gameTree, GamePlayer informedPlayer, GameInfo info)
        {
            var action = new OldFuegoAction(this, () => {
                FixHistory(new AiGameInformation(info, informedPlayer.Info.Color, informedPlayer, gameTree));
                return(default(AIDecision));
            });

            EnqueueAction(action);
        }
Esempio n. 2
0
        /// <summary>
        /// Informs the AI engine that a move was just undone. Stateful AIs (i.e. Fuego) use this.
        /// <para>
        /// This is called synchronously in the main thread by the game controller or the assistant.
        /// </para>
        /// </summary>
        public override void MoveUndone()
        {
            var action = new OldFuegoAction(this, () => {
                UndoOneMove();
                return(default(AIDecision));
            });

            EnqueueAction(action);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a hint from the AI.
        /// <para>
        /// This is called ASYNCHRONOUSLY by the assistant.
        /// </para>
        /// </summary>
        /// <param name="gameInformation"></param>
        /// <returns></returns>
        public override AIDecision GetHint(AiGameInformation gameInformation)
        {
            var action = new OldFuegoAction(this, () =>
            {
                var result = TrueRequestMove(gameInformation);
                UndoOneMove();
                return(result);
            });

            EnqueueAction(action);
            return(action.GetAiDecisionResult());
        }
Esempio n. 4
0
        /// <summary>
        ///     Gets all positions that the Fuego engines consider dead in its current state (as arrived at by its own moves,
        ///     RequestMoves calls
        ///     and MovePerformed/MoveUndone calls. Currently this is not multithreaded for ease of debugging.
        /// <para>
        ///     This is called synchronously in the main thread by the assistant.
        /// </para>
        /// </summary>
        /// <param name="gameController"></param>
        /// <returns></returns>
        public override async Task <IEnumerable <Position> > GetDeadPositions(IGameController gameController)
        {
            var action = new OldFuegoAction(this, () =>
            {
                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);
        }
Esempio n. 5
0
 private void EnqueueAction(OldFuegoAction action)
 {
     _fuegoActions.Enqueue(action);
     ExecuteQueueIfNotRunning();
 }