/// <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); }
/// <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); }
/// <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()); }
/// <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); }
private void EnqueueAction(OldFuegoAction action) { _fuegoActions.Enqueue(action); ExecuteQueueIfNotRunning(); }