diff --git a/docs/MEASUREMENT_3_7.md b/docs/MEASUREMENT_3_7.md index 65ea39a..157cf83 100644 --- a/docs/MEASUREMENT_3_7.md +++ b/docs/MEASUREMENT_3_7.md @@ -39,9 +39,15 @@ separately, see below). The other two are explained: ## Indoor tournament -All eleven recorded rounds play their 40 minutes with the same random draws as the original. At the kick-off, however, -the six strength values of the side records differ by 1 to 4 points in about half of the rounds (the port is mostly -higher); ordinary matches show no such difference. This is tracked as issue 82. The desk after the round is identical in +All eleven recorded rounds play their 40 minutes with the same random draws as the original. The six strength values +of the side records at the kick-off first differed by 1 to 4 points in about half of the rounds (the port mostly +higher). Cause (issue 82, resolved): the strengths depend on the **chance weather**, a runtime value that the +original keeps from the last chance of the round before (rain above 2 or a temperature below 0 lowers players +whose condition is below their technique). A savegame does not hold it, and the checker starts every turn from a +savegame, so it had rain 0 / temperature 0. With the weather of the previous turn's last chance +(`WEEK_PREV_WEATHER=rain,temperature`, taken from the "last chance weather" line of the previous check) the kick-off +of **all eleven rounds is identical**, bytes 0 to 5 of every side. A running game keeps the weather in memory +like the original, so this was a gap of the check and not of the engine. The desk after the round is identical in ten of eleven rounds (the eleventh is the tournament end above). ## How to read the "DIFF" lines of the checker diff --git a/tests/week_check.cpp b/tests/week_check.cpp index 91870dc..7d80084 100644 --- a/tests/week_check.cpp +++ b/tests/week_check.cpp @@ -1756,6 +1756,13 @@ const Entry* desk = &pause; // (after an offer message box the next pause) std::printf("indoor round: desk (date %s) -> kick-off -> minute 40 -> pause\n", field(desk.line, "date").c_str()); GameState s = saved; s.texts = &textdb; + if (const char* pw = std::getenv("WEEK_PREV_WEATHER")) { + // The chance weather is a runtime value that the savegame does not hold: the kick-off of an indoor + // round still rates the sides with the weather of the last chance of the round before (printed as + // "last chance weather" by the check of the previous turn): WEEK_PREV_WEATHER=rain,temperature + int rain = 0, temp = 0; + if (std::sscanf(pw, "%d,%d", &rain, &temp) == 2) s.chance_rain = rain, s.chance_temperature = temp; + } if (i1 < entries.size() && !field(entries[i1].state, "a3d4c").empty()) s.trend_rotation = std::stoi(field(entries[i1].state, "a3d4c")); if (!field(desk.state, "results").empty()) { @@ -1783,6 +1790,105 @@ const Entry* desk = &pause; // (after an offer message box the next pause) } if (!sk.unsupported) kick_off(s, sat, sc, sr0, sg0, sk); if (sk.unsupported) std::printf(" not supported: %s\n", sk.reason.c_str()); + if (i1 < entries.size() && std::getenv("WEEK_INDOOR_WEATHER")) { + // development helper: the (runtime only) chance weather that reproduces the recorded kick-off sides + // of the indoor round (sides 0..5 except byte 2) for the first match of every group + const std::vector rec_in = groups_from_snapshot(entries[i1].line); + for (size_t gi = 0; gi < sat.size() && gi < rec_in.size(); gi++) + for (int rain = 0; rain < 20; rain++) + for (int temp = -30; temp < 50; temp++) { + bool same = true; + for (size_t side = 0; side < 4 && same && side < sat[gi].fixtures.size(); side++) + for (int i = 0; i < 6 && same; i++) { + if (i == 2) continue; + GameState copy = s; + RatingContext rc{rain, temp}; + WatcomRandom wr = sr0; + GameRandom gr = sg0; + rc.rand = &wr, rc.game = &gr; + const int v = team_rating(copy, sat[gi].fixtures[side], kRatingProfiles[i], rc); + if (side * 9 + size_t(i) < rec_in[gi].records.size() && + v != rec_in[gi].records[side * 9 + size_t(i)]) + same = false; + } + if (same) std::printf(" group %zu: chance weather rain %d temperature %d reproduces the sides\n", gi, rain, temp); + } + } + if (i1 < entries.size() && std::getenv("WEEK_INDOOR_TABLE")) { + // development helper: the six ratings of every side with the formation table at offset k*0xB0 + const std::vector rec_in = groups_from_snapshot(entries[i1].line); + std::printf(" formations table size %zu\n", s.formations.size()); + for (size_t gi = 0; gi < sat.size() && gi < rec_in.size(); gi++) + for (size_t side = 0; side < sat[gi].fixtures.size() && (side + 1) * 9 <= rec_in[gi].records.size(); side++) { + const int team = sat[gi].fixtures[side]; + if (s.manager_of(team) >= 0) continue; + std::printf(" g%zu team %3d orig:", gi, team); + for (int i = 0; i < 6; i++) std::printf(" %02x", rec_in[gi].records[side * 9 + size_t(i)]); + std::printf("\n"); + if (!field(entries[i1].state, "squad_slots").empty()) { + // the same ratings from the recorded tables of minute 1 (players, flags, morale, bonus) + GameState rs = state_from_dump(entries[i1].state); + rs.formations = s.formations, rs.indoor = true, rs.level = s.level, rs.texts = s.texts; + RatingContext rc{s.chance_rain, s.chance_temperature}; + std::printf(" recorded tables:"); + for (int i = 0; i < 6; i++) std::printf(" %02x", team_rating(rs, team, kRatingProfiles[i], rc)); + std::printf("\n"); + const SquadRange r = squad_range(team); + for (size_t k = r.first; k < r.first + r.count; k++) { + const int pl = s.squad_slots[k] & 0xfff; + if (pl == 0xfff) break; + const Player& a = s.players.at(size_t(pl)); + const Player& o = rs.players.at(size_t(pl)); + if (a.w35c != o.w35c || a.w364 != o.w364 || a.w368 != o.w368 || + s.player_bonus.at(size_t(pl)) != rs.player_bonus.at(size_t(pl))) + std::printf(" player %d: w35c %08x/%08x w364 %08x/%08x w368 %08x/%08x bonus %02x/%02x\n", pl, + unsigned(a.w35c), unsigned(o.w35c), unsigned(a.w364), unsigned(o.w364), unsigned(a.w368), + unsigned(o.w368), s.player_bonus.at(size_t(pl)), rs.player_bonus.at(size_t(pl))); + } + if (s.team_morale.at(size_t(team)) != rs.team_morale.at(size_t(team))) + std::printf(" morale %02x/%02x\n", s.team_morale.at(size_t(team)), rs.team_morale.at(size_t(team))); + } + if (std::getenv("WEEK_INDOOR_WEATHER")) { + // AI sides only: the chance weather that reproduces bytes 0, 1 and 3 + int found = 0; + for (int rain = 0; rain < 20 && found < 6; rain++) + for (int temp = -30; temp < 50 && found < 6; temp++) { + bool same = true; + for (int i : {0, 1, 3}) { + GameState copy = s; + RatingContext rc{rain, temp}; + if (team_rating(copy, team, kRatingProfiles[i], rc) != rec_in[gi].records[side * 9 + size_t(i)]) same = false; + } + if (same) found++, std::printf(" weather rain %d temp %d reproduces bytes 0,1,3\n", rain, temp); + } + if (!found) std::printf(" no weather reproduces bytes 0,1,3\n"); + } + for (size_t k = 0; k * 0xB0 + 0xB0 <= s.formations.size(); k++) { + GameState copy = s; + for (size_t i = 0; i < 0xB0; i++) copy.formations[0xB0 + i] = s.formations[k * 0xB0 + i]; + RatingContext rc{s.chance_rain, s.chance_temperature}; + std::printf(" table %zu:", k); + for (int i = 0; i < 6; i++) std::printf(" %02x", team_rating(copy, team, kRatingProfiles[i], rc)); + std::printf("\n"); + } + } + } + if (i1 < entries.size() && std::getenv("WEEK_INDOOR_LINEUP") && !field(entries[i1].state, "squad_slots").empty()) { + // development helper: line-ups (squad slots with the line-up bit) of the port against the recording + const GameState rs = state_from_dump(entries[i1].state); + for (const MatchGroup& grp : sat) + for (int team : grp.fixtures) { + const SquadRange r = squad_range(team); + std::printf(" lineup team %3d:", team); + for (int pass = 0; pass < 2; pass++) { + const GameState& st = pass == 0 ? s : rs; + std::printf(pass == 0 ? " ours" : " | orig"); + for (size_t k = r.first; k < r.first + r.count && k < st.squad_slots.size(); k++) + if (st.squad_slots[k] & 0x8000) std::printf(" %d/%d", int(k - r.first), st.squad_slots[k] & 0xfff); + } + std::printf("\n"); + } + } if (i1 < entries.size()) { std::printf(" kick-off against minute 1:\n"); compare_kickoff(sat, groups_from_snapshot(entries[i1].line), &s);