What came from the game now comes through YGOLegacy.Bots.BotHost (Host/BotHost.cs): Log (was UnityEngine.Debug), Cards (the SQLite connection; was Mono.Data.Sqlite), Files (locale and the expansions' .cdb; was MDPro3 Language/ResourceManager, GamePaths.PATH_EXPANSIONS), DeckLimits (#ruleset -> caps; was the game's DeckLimits/Rulesets) and BotConf (bot.conf; was SoloLoader). CharacterRegistry loses its UniTask surface and keeps Scan/Publish (now public) and LoadFromDisk. No YGOL_STANDALONE branches are left. Internals stay internal, visible to Assembly-CSharp(-Editor), BotArena and the tests. References the engine release's binding (engine.json pins v1.4.1). No change to how the bots play. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
3.8 KiB
C#
83 lines
3.8 KiB
C#
using System;
|
|
using WindBot.Game;
|
|
|
|
namespace YGOLegacy.Bot
|
|
{
|
|
// ------------------------------------------------------------------------
|
|
// TICKET-050 — rollout ("lookahead") planning for the idle command.
|
|
//
|
|
// The two halves of the hook live here so that neither the WindBot seam nor
|
|
// SmartExecutor has to know which oracle (if any) is installed:
|
|
//
|
|
// IIdlePlanner what the [YGOL] seam in GameAI.OnSelectIdleCmd looks
|
|
// for on the executor. SmartExecutor implements it.
|
|
// ILookaheadOracle what can actually produce a "future" for the duel
|
|
// currently in progress. NOTHING implements it inside the
|
|
// game: ocgcore cannot clone a live duel, so the only
|
|
// implementation is the arena's perfect-information
|
|
// ReplayOracle (src/BotArena/ReplayOracle.cs).
|
|
//
|
|
// With no oracle installed — every in-game duel today — SmartExecutor's
|
|
// planner declines and the executor walk runs exactly once, unchanged.
|
|
// ------------------------------------------------------------------------
|
|
|
|
/// <summary>
|
|
/// An executor that wants to choose its idle command by re-running the
|
|
/// WindBot executor walk under a veto set (see the [YGOL] seam in
|
|
/// <c>GameAI.OnSelectIdleCmd</c>).
|
|
/// </summary>
|
|
public interface IIdlePlanner
|
|
{
|
|
/// <summary>
|
|
/// Cheap gate asked before anything is copied or walked: false = the
|
|
/// seam behaves exactly as upstream.
|
|
/// </summary>
|
|
bool YGOL_WantsPlan();
|
|
|
|
/// <summary>
|
|
/// Pick an idle action. <paramref name="walk"/> runs the executor walk
|
|
/// with an "is this action allowed" predicate; returning a growing veto
|
|
/// set enumerates the executor's own top-K preferences in order.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// The chosen <c>MainPhaseAction.ToValue()</c>, or null to fall back to
|
|
/// the plain walk. The caller re-runs the walk restricted to the chosen
|
|
/// value, so this method must not leave side effects behind.
|
|
/// </returns>
|
|
int? YGOL_PlanIdle(MainPhase main, Func<Func<MainPhaseAction, bool>, MainPhaseAction> walk);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Something that can play the current duel forward from the prompt being
|
|
/// answered right now and say how a candidate answer turned out.
|
|
/// </summary>
|
|
public interface ILookaheadOracle
|
|
{
|
|
/// <summary>False = do not even try (no host attached, budget spent, …).</summary>
|
|
bool Available { get; }
|
|
|
|
/// <summary>
|
|
/// Value of answering the CURRENT idle prompt with
|
|
/// <paramref name="idleResponse"/> (a <c>MainPhaseAction.ToValue()</c>),
|
|
/// in 0..1 — 1 = we won every rollout, 0 = we lost every rollout.
|
|
/// <see cref="float.NaN"/> = could not be evaluated (the rollout
|
|
/// desynced, the budget ran out, …), which the caller treats as
|
|
/// "evaluator only".
|
|
/// </summary>
|
|
/// <param name="rollouts">playouts to average (knob <c>lookahead</c>).</param>
|
|
/// <param name="horizonTurns">
|
|
/// stop this many turns past the current one and score the position
|
|
/// instead of playing to the end (knob <c>lookaheadTurns</c>; 0 = play
|
|
/// to the end).
|
|
/// </param>
|
|
/// <param name="msBudget">
|
|
/// wall-clock ceiling for this whole call (knob <c>lookaheadMs</c>);
|
|
/// the oracle returns what it has when the budget is gone.
|
|
/// </param>
|
|
float Evaluate(int idleResponse, int rollouts, int horizonTurns, int msBudget);
|
|
|
|
/// <summary>Human-readable note about the last <see cref="Evaluate"/> (for the log).</summary>
|
|
string LastNote { get; }
|
|
}
|
|
}
|