Hold back live chance statistics until the result of the chance
Prepare verified release / draft (push) Waiting to run

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-11-07 15:09:38 +01:00
1 parent 09b92c9b2a
commit 93ca832c71
5 files changed
+44 -5

No files matched your search

+7 -3
View File
@@ -28,6 +28,10 @@ compared with the engine; every difference found was ported and documented.
was inverted in the port (older players were recycled the wrong way round);
this is fixed.
- **Season end.** Retirement and leave rules for the player slots.
- **Live match statistics.** The chance counters at the bottom of the live
matchday screen counted a chance as soon as the engine logged it, before the
presentation started. They are now held back like the score and appear with
the result of the chance.
## What was measured, what was derived
@@ -47,9 +51,9 @@ in the source as a known gap).
## Open points
Reported by the Diamond author and not changed here: bug in "fetch player from
transfer market / check offers", and the chance counters at the bottom of the
match screen count up slightly too early. Earlier open points remain: the
Reported by the Diamond author and not changed here: the bug in "fetch player
from transfer market / check offers" (exact steps still to be reproduced).
Earlier open points remain: the
"player card: original atlas bounds" error (#77), sporadic double clicks (#58)
and the macOS match scene speed (#70).
+4 -1
View File
@@ -3291,7 +3291,10 @@ int main(int argc, char** argv) {
}, [&](const LiveChanceEvent& event, const std::vector<MatchGroup>& groups,
const GameState& state) {
if (!running || live_skipped) return;
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
// Preview: the chance is already in the event log, but its statistics must not count yet.
const auto frame = event.stage == LiveChanceStage::preview
? ui::live_matchday_frame_before_chance(event.minute, groups, state, event)
: ui::live_matchday_frame(event.minute, groups, state);
live_score_reveal.observe(event.stage, frame);
if (frame.matches.empty()) return;
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
+12
View File
@@ -140,6 +140,18 @@ LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>&
return frame;
}
LiveMatchdayFrame live_matchday_frame_before_chance(int minute, const std::vector<MatchGroup>& groups,
const GameState& state, const LiveChanceEvent& event) {
// MatchEngine::chance writes two log pairs (outcome, then kind/distance) = 4 words before the preview hook.
// The copy is small: chances are rare and only the log of one group is shortened.
if (event.group < 0 || size_t(event.group) >= groups.size() || groups[size_t(event.group)].log.size() < 4)
return live_matchday_frame(minute, groups, state);
std::vector<MatchGroup> before = groups;
auto& log = before[size_t(event.group)].log;
log.resize(log.size() - 4);
return live_matchday_frame(minute, before, state);
}
LiveChanceProjection live_chance_projection(const LiveChanceEvent& event,
const std::vector<MatchGroup>& groups, const GameState& state, const LeImage& exe) {
if (event.group < 0 || size_t(event.group) >= groups.size() || event.match < 0 ||
+9 -1
View File
@@ -51,8 +51,14 @@ struct LiveMatchdayFrame {
LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>& groups,
const GameState& state);
// Frame of the matchday as it looked before the chance of the event was written to the event log. The engine
// logs a chance (two log pairs) before its preview hook, so the statistics rows (chances, shots, ...) would
// otherwise count it before the presentation has even started.
LiveMatchdayFrame live_matchday_frame_before_chance(int minute, const std::vector<MatchGroup>& groups,
const GameState& state, const LiveChanceEvent& event);
// The engine commits a chance before its ball/set-piece/shot presentation. Keep
// the observed preview scores until the result hook, without delaying simulation.
// the observed preview scores and statistics until the result hook, without delaying simulation.
class LiveScoreReveal {
public:
void observe(LiveChanceStage stage, const LiveMatchdayFrame& frame) {
@@ -66,6 +72,8 @@ public:
row.home_goals = before.home_goals;
row.away_goals = before.away_goals;
row.score_known = before.score_known;
row.home_stats = before.home_stats;
row.away_stats = before.away_stats;
break;
}
return frame;
+12
View File
@@ -26,6 +26,18 @@ int main() {
reveal.observe(bmh::LiveChanceStage::result,resolved);
if(reveal.project(resolved)!=resolved)throw std::runtime_error("result did not reveal goal");
}
// Statistics (chances, shots, ...) count a chance only at its result, like the score.
{
LiveScoreReveal stats_reveal;
stats_reveal.observe(bmh::LiveChanceStage::preview,frame);
auto counted=frame;counted.matches[0].home_stats={11,4,2,1};counted.matches[0].away_stats={11,3,0,0};
counted.matches[0].home_stats[1]++;
const auto shown=stats_reveal.project(counted);
if(shown.matches[0].home_stats!=frame.matches[0].home_stats||shown.matches[0].away_stats!=frame.matches[0].away_stats||
shown.matches[1]!=counted.matches[1])throw std::runtime_error("statistics counted before the result");
stats_reveal.observe(bmh::LiveChanceStage::result,counted);
if(stats_reveal.project(counted)!=counted)throw std::runtime_error("result did not reveal statistics");
}
reveal.observe(bmh::LiveChanceStage::preview,frame);
if(reveal.project(frame)!=frame)throw std::runtime_error("miss changed score");
auto next=frame;next.minute++;