revert(battle-node): remove real-spin logic (CountHiddenDraws + per-frame spin)

Two-sided capture (data_dumps/captures/battle_test/rng, 2026-06-04) showed the
receiver already reproduces uList-relayed deck fetches (Hoverboard) and turn
draws on its own shared stream, so the emitted spin=1 double-cranked and desynced
the clients by 1. Residual spin is ~0 for the current card pool. Reverts 63cb324
and 617714e; back to the prior correct spin:0 behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-04 16:07:08 -04:00
parent 617714ebea
commit 75f3d8ea5b
5 changed files with 4 additions and 217 deletions

View File

@@ -8,18 +8,15 @@ namespace SVSim.BattleNode.Protocol.Bodies;
/// (independent of KnownList — a targeted hand play carries both). <c>KeyAction</c> forwards a
/// choice/Discover play's <c>{type,cardId}</c> so the opponent renders the choice-token generation;
/// the pick (<c>selectCard</c>) is stripped for a hidden (open:0) draw-to-hand choice. <c>UList</c>
/// forwards the sender's unapproved-movement list (deck-sourced summons/fetches) verbatim. <c>Spin</c>
/// is the count of hidden, non-reproduced shared-RNG draws in THIS frame (real-spin design §3.2,
/// per-frame delivery); null/omitted = 0 (the client's assumed default). All are omitted when null
/// via the envelope's WhenWritingNull policy (a vanilla play carries none).</summary>
/// forwards the sender's unapproved-movement list (deck-sourced summons/fetches) verbatim. All are
/// omitted when null via the envelope's WhenWritingNull policy (a vanilla play carries none).</summary>
public sealed record PlayActionsBroadcastBody(
[property: JsonPropertyName("playIdx")] int PlayIdx,
[property: JsonPropertyName("type")] int Type,
[property: JsonPropertyName("knownList")] IReadOnlyList<KnownCardEntry>? KnownList,
[property: JsonPropertyName("oppoTargetList")] IReadOnlyList<OppoTargetEntry>? OppoTargetList,
[property: JsonPropertyName("uList")] IReadOnlyList<UnapprovedCardEntry>? UList = null,
[property: JsonPropertyName("keyAction")] IReadOnlyList<KeyActionEntry>? KeyAction = null,
[property: JsonPropertyName("spin")] int? Spin = null) : IMsgBody;
[property: JsonPropertyName("keyAction")] IReadOnlyList<KeyActionEntry>? KeyAction = null) : IMsgBody;
/// <summary>Opponent-facing keyAction entry for a choice/Discover play. <c>type</c>/<c>cardId</c>
/// (the GENERATING card) pass through so the opponent re-derives the candidate pool from that card's

View File

@@ -48,17 +48,6 @@ internal sealed class PlayActionsHandler : IFrameHandler
// knownList in the same frame (capture line 75).
var uList = KnownListBuilder.RelayUList(entries.GetValueOrDefault("uList"));
// Hidden shared-RNG draws (a random deck→hand fetch the opponent can't reproduce) advance the
// sender's shared _stableRandom; the receiver doesn't re-run them, so it needs a spin crank to
// stay aligned for later visible randoms. Per-frame delivery (real-spin design §3.2): the count
// rides THIS PlayActions. A fetch we relay with an identity (uList cardId present) is already
// known to the opponent — exclude its idxs so it isn't counted. 0 → null (omitted; client
// assumes spin:0).
var revealed = uList is null
? (IReadOnlySet<int>)new HashSet<int>()
: uList.Where(u => u.CardId is not null).SelectMany(u => u.IdxList).ToHashSet();
var spin = KnownListBuilder.CountHiddenDraws(orderList, playIdx, revealed);
var body = new PlayActionsBroadcastBody(
PlayIdx: playIdx,
Type: type,
@@ -67,8 +56,7 @@ internal sealed class PlayActionsHandler : IFrameHandler
UList: uList,
// {type,cardId} forwarded so the opponent renders the choice token; selectCard dropped
// when open==0 (hidden draw-to-hand pick). Null for a vanilla play (no keyAction).
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction),
Spin: spin > 0 ? spin : null);
KeyAction: KnownListBuilder.StripKeyActionForOpponent(keyAction));
var frame = ctx.Env with { Body = body };
return new[] { new DispatchRoute(ctx.Other, frame, false) };

View File

@@ -42,41 +42,6 @@ internal static class KnownListBuilder
return null;
}
/// <summary>Count hidden, non-reproduced shared-RNG draws implied by an orderList: <c>move</c> ops
/// from Deck(0) to Hand(10) for a non-played, unrevealed card (a random fetch the opponent can't
/// reproduce — it can't enumerate the active player's deck). Each such moved card = one crank the
/// receiver must apply (<c>spin += 1</c>). Skips: the played card's own move (<c>idx == playIdx</c>);
/// any idx in <paramref name="revealed"/> (its identity is already on the wire — a revealed uList
/// fetch); and lot-based randoms (a <c>move</c> op carrying a <c>rand</c> array — the receiver
/// reproduces those by re-rolling, so counting would double-crank). An ordinary card DRAW also
/// surfaces as a hidden <c>move(0→10)</c> but is a deterministic top-of-deck pop (no shared-stream
/// roll) and must NOT be counted — distinguishing it from a random fetch on the wire is the open
/// capture (real-spin design §3.1; the spec's Task 0). Base 0; see the real-spin design doc.</summary>
public static int CountHiddenDraws(object? orderList, int playIdx, IReadOnlySet<int> revealed)
{
if (orderList is not IEnumerable<object?> ops) return 0;
var count = 0;
foreach (var op in ops)
{
if (op is not IDictionary<string, object?> opDict) continue;
if (!opDict.TryGetValue("move", out var moveRaw) || moveRaw is not IDictionary<string, object?> move) continue;
if (move.ContainsKey("rand")) continue; // lot random → receiver re-rolls
if (!move.TryGetValue("from", out var fromRaw) || (int)AsLong(fromRaw) != 0) continue; // not from Deck
if (!move.TryGetValue("to", out var toRaw) || (int)AsLong(toRaw) != 10) continue; // not to Hand
if (!move.TryGetValue("idx", out var idxRaw) || idxRaw is not IEnumerable<object?> idxList) continue;
foreach (var i in idxList)
{
var idx = (int)AsLong(i);
if (idx == playIdx) continue; // the played card's own move
if (revealed.Contains(idx)) continue; // opponent already knows this card's identity
count++;
}
}
return count;
}
/// <summary>Mine generated-token identities from a sender's <c>add</c> ops: yields
/// <c>(idx, cardId, isSelf)</c> for every idx in each <c>{add:{idx:[...], isSelf, card:{cardId}}}</c>
/// op. <c>isSelf</c> is surfaced verbatim (the sender's perspective tag on <c>CardObj.IsPlayer</c>,