Rank Modern clubs by the data set's player values (M7)

The original draws new values for every league player at the career
start, so the data set's values were never calibrated for play; taken
as they are they give clubs far outside their league's strength
(spread 14-21 instead of about 6, 3.3 goals per match). In a Modern
world the clubs of a league now take the places of the league's
strength band in the order of the data set, and their players keep
their distances to the club level, compressed to the spread of
generated players. The human club and swapped clubs move as a whole.
Two seasons: 2.77 goals per match (original 2.67), plausible tables.

MODERN_SPREAD=1 prints the club strengths per league at the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-24 09:41:06 +02:00
1 parent 0a6be70046
commit 4f6ec1e240
6 files changed
+164 -4

No files matched your search

+2
View File
@@ -31,6 +31,7 @@ describe deliberate changes; they are not a list of every known compatibility li
- [src/modern/app/modern_session.cpp](../src/modern/app/modern_session.cpp): supports designated set-piece record initialization and validation.
- [src/modern/app/modern_session.cpp](../src/modern/app/modern_session.cpp): native saves do not consume gameplay randomness for encryption.
- [src/modern/content/world_expand.cpp](../src/modern/content/world_expand.cpp): Modern worlds have league sizes, clubs and players of their own; players whose nation has no single-byte nationality code carry a substitute foreign code.
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): in a Modern world a club's place in the strength band of its league follows the data set's ranking of the squads instead of the table place, and its players keep their relative values (balance.md).
- [src/modern/game/career.cpp](../src/modern/game/career.cpp): skips reserved calendar positions when assigning a joining manager to a club.
- [src/modern/game/career.hpp](../src/modern/game/career.hpp): uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
- [src/modern/game/desk_actions.cpp](../src/modern/game/desk_actions.cpp): uses the supported transfer-fee arithmetic and designated set-piece fields.
@@ -45,6 +46,7 @@ describe deliberate changes; they are not a list of every known compatibility li
- [src/modern/game/week.hpp](../src/modern/game/week.hpp): uses the enhanced assistant-training rules, retaining the selected skill until it reaches its maximum.
- [src/modern/game/weekly.cpp](../src/modern/game/weekly.cpp): uses the supported weekly-event configuration, with its rule switch disabled.
- [src/modern/game/weekly.hpp](../src/modern/game/weekly.hpp): uses the supported weekly processing and transfer rule profile.
- [src/modern/ui/demo_calendar.cpp](../src/modern/ui/demo_calendar.cpp): the native season follows its saved start year (including leap days), rather than the HTML's fixed 2027/28.
- [src/ui/league_table.hpp](../src/ui/league_table.hpp): uses three points for a win in the supported rule profile.
- [src/ui/pitch.cpp](../src/ui/pitch.cpp): supports owner-bound designated set-piece selection in the extended manager record.
- [src/ui/save_load.cpp](../src/ui/save_load.cpp): focuses the host save filename on entry and selects an existing name for replacement.
+1 -1
View File
@@ -58,7 +58,7 @@ Für 0.3 gilt außerdem:
| M4 | Trainingslager: 18 Lager, drei Karten, 6-Sterne-Wirkung | Engine erledigt (Katalog, Preis, 6-Sterne-Wirkung, Test); Saisonwirkung wird in M7 gemessen |
| M5 | Datenrevision 1.4 des Modern-Datensatzes (privat), Wirtschaftsprüfung | offen |
| M6 | Modern-Spielstände (`modern-career-v1`), Projektionen für die UI | Spielstände erledigt (Rundreise identisch); Projektionen offen |
| M7 | Balance-Läufe und Anpassungen | offen |
| M7 | Balance-Läufe und Anpassungen | begonnen: Spielerwerte des Datensatzes nach Rangfolge ([Balance](balance.md)); Langläufe offen |
| M8 | Fußball-Almanach: alle Spiele mit Ereignissen und Aufstellungen ([Almanach](almanach.md)) | Engine erledigt (Aufzeichnung, Spielstand, IDs); UI und Projektionen offen |
Details und Abnahmekriterien stehen in [Phasen](phasen.md).
+36
View File
@@ -0,0 +1,36 @@
# Balance (M7)
Laufende Notizen zur Balance der Modern-Engine: Befunde, Entscheidungen von Michael, Messungen.
## Spielerwerte des Datensatzes
**Befund (24.10.2026):** Beim Karrierestart würfelt das Original (`startup_players`, CareerFirstSteps2) Kondition, Technik, Form und Eigenschaften **aller** Ligaspieler neu, nach Liga und Tabellenplatz (Stärkebänder `kLeagueStrength`, z. B. Bundesliga 71–93). Die Werte der Datenbank haben im Original deshalb nie gespielt. Im Modern-Datensatz blieben so 0 von 400 Spielern bei ihren Werten.
Die Werte des Datensatzes passen zwischen den Vereinen nicht zur Spielstärke: Wolfsburg (2. Liga) 92, stärker als jeder Bundesligist, Elversberg (Bundesliga) 42, Kaiserslautern (2. Liga) 28. Streuung der Vereinsstärke (Mittel der besten 14) in den deutschen Ligen 14–21 Punkte statt rund 6 im Original. 1:1 übernommen ergab das 3,3 Tore pro Spiel und Tabellen mit 100 bzw. 6 Punkten.
**Entscheidung (Michael): Rangfolge übernehmen.**
- Die Vereine einer Liga nehmen die Plätze im Stärkeband der Liga nach der Rangfolge im Datensatz ein (Mittel von Kondition und Technik der besten 14), statt nach dem Tabellenplatz.
- Innerhalb des Kaders behalten die Spieler ihren Abstand zum Vereinsniveau, gestaucht auf die Streuung erzeugter Spieler (W(Niveau ± 10 %), Standardabweichung ≈ 5,8 % des Niveaus), wo der Kader breiter ist. Form und Eigenschaften bleiben aus dem Datensatz.
- Der Verein des Menschen (Mannschaftsstärke beim Start) und Vereine, die beim Start den Platz tauschen, werden als Ganzes auf ihr Niveau verschoben; die Abstände bleiben.
- Neue Personen (Jugend, Ersatz für Abgänge) erzeugt die Engine wie das Original; ihre Werte liegen damit auf derselben Skala.
- Ohne Modern-Welt (Classic-Daten) ändert sich nichts.
Code: `src/modern/game/career.cpp` (`startup_players`, `set_club_strength`, `place_club`), `keeps_world_values` in `modern_state.hpp`.
**Messung (Modern-Datensatz, Seed 1, zwei Saisons):**
| | Original (gewürfelt) | Datensatz 1:1 | Rangfolge |
|---|---|---|---|
| Tore pro Spiel | 2,67 | 3,27 | 2,77 |
| Vereinsstärke Bundesliga (min–max) | 71–93 | 42–91 | 72–93 |
| Streuung Bundesliga / 2. Liga | ≈ 6 / 6 | 13,7 / 17,4 | 6,3 / 6,4 |
| Bundesliga-Meister / Letzter | – | 79 / 15 Pkt. | 75–77 / 15–18 Pkt. |
Messwerkzeug: `MODERN_SPREAD=1 modern_season_sim <welt.obw> 1 0 1` zeigt die Vereinsstärken je Liga beim Start.
## Offen
- Trainingslager: Saisonwirkung von 6 Sternen messen (Ziel: höchstens etwa +1 Tabellenplatz).
- Ermüdung und Verletzungen bei 38 Spieltagen, Marktwerte und Gehälter der neuen Spieler, Finanzen des menschlichen Vereins (Langläufe über 10 Saisons).
- Spieler in den Pools (vereinslos) aus dem Datensatz behalten ihre Rohwerte; der Datensatz 1.3 hat keine.
- Datenpflege: Die Werte im Datensatz könnten auf eine gemeinsame Skala gebracht werden; die Engine braucht das wegen der Rangfolge nicht.
+91 -3
View File
@@ -4,6 +4,9 @@
#include "modern/game/career.hpp"
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include "game/messages.hpp"
#include "game/schedule.hpp"
@@ -48,10 +51,88 @@ std::vector<uint16_t> startup_squad_list(const Database& db) {
return slots;
}
namespace {
// --- Modern worlds: the data set's players on the engine's strength scale (balance.md) --------
// The values of a data set were never part of the play in the original (it draws new ones at
// the career start), so their scale differs from club to club. Modern keeps who is strong:
// the clubs of a league take the places of the league's strength band in the order of the
// data set, and within a squad the players keep their distances to the club's level.
// The club takes part when its squad has a player of the data set.
bool world_club(const ModernState& g, int team) {
const SquadRange r = squad_range(team);
for (size_t s = r.first; s < r.first + r.count; s++)
if (keeps_world_values(g, g.squad_slots.at(s) & 0x0fff)) return true;
return false;
}
// The players of a squad by their mean of condition and technique, best first.
std::vector<double> squad_values(const ModernState& g, int team) {
std::vector<double> v;
const SquadRange r = squad_range(team);
for (size_t s = r.first; s < r.first + r.count; s++) {
const int id = g.squad_slots.at(s) & 0x0fff;
if (id != 0x0fff) v.push_back((g.players.at(size_t(id)).condition() + g.players.at(size_t(id)).technique()) / 2.0);
}
std::sort(v.rbegin(), v.rend());
return v;
}
// The club's level in the data set: the mean of its best 14 players.
double club_anchor(const ModernState& g, int team) {
const auto v = squad_values(g, team);
const size_t n = std::min<size_t>(14, v.size());
double sum = 0;
for (size_t i = 0; i < n; ++i) sum += v[i];
return n ? sum / double(n) : 0;
}
// Moves the data set's players of a squad to `level`: each keeps his distance to the club's
// anchor, compressed (compress) to the spread of generated players (W(level +- 10 %), sd about
// 5.8 % of the level) where the squad is wider. Condition and technique 10-99 as GeneratePlayer.
void place_club(ModernState& g, int team, int level, bool compress) {
const double anchor = club_anchor(g, team);
double k = 1.0;
if (compress) {
const auto v = squad_values(g, team);
const size_t n = std::min<size_t>(14, v.size());
double var = 0;
for (size_t i = 0; i < n; ++i) var += (v[i] - anchor) * (v[i] - anchor);
const double sd = n > 1 ? std::sqrt(var / double(n)) : 0;
const double target = level * 0.2 / std::sqrt(12.0);
if (sd > target) k = target / sd;
}
auto place = [&](int value) {
return std::clamp(int(std::lround(level + (value - anchor) * k)), 10, 0x63);
};
const SquadRange r = squad_range(team);
for (size_t s = r.first; s < r.first + r.count; s++) {
const int id = g.squad_slots.at(s) & 0x0fff;
if (!keeps_world_values(g, id)) continue;
Player& p = g.players.at(size_t(id));
const uint32_t condition = uint32_t(place(p.condition())), technique = uint32_t(place(p.technique()));
p.w35c = (p.w35c & 0xffe0007fu) | condition << 14 | technique << 7;
}
}
} // namespace
void startup_players(ModernState& g, GameRandom& game, WatcomRandom& rand) {
for (size_t i = 0; i < 0x36; i++) {
const int level = rand.range(i < 0x16 ? 0x14 : 0x46, 0x5a);
modern::generate_player(g, int16_t(g.squad_slots.at((pool_end_slot() + 24) + i)), int16_t(level), game, rand);
const int id = int16_t(g.squad_slots.at((pool_end_slot() + 24) + i));
if (!keeps_world_values(g, id)) modern::generate_player(g, id, int16_t(level), game, rand);
}
// OpenBMH deviates from the original: in a Modern world a club's place in the strength band of its league follows the data set's ranking of the squads instead of the table place, and its players keep their relative values (balance.md).
std::vector<int> ranked(size_t(league_clubs()), -1);
for (int league = 0; league < kLeagueCount; ++league) {
std::vector<std::pair<double, int>> clubs;
const int first = league_first_team(league);
for (int team = first; team < first + int(kLeagueSizes[league]) && team < league_clubs(); ++team)
if (world_club(g, team)) clubs.emplace_back(-club_anchor(g, team), team);
std::stable_sort(clubs.begin(), clubs.end());
for (size_t i = 0; i < clubs.size(); ++i) ranked[size_t(clubs[i].second)] = int(i);
}
int previous = 0, index = -1; // local_18, local_1c
for (int team = 0; team < league_clubs(); team++) {
@@ -60,11 +141,13 @@ void startup_players(ModernState& g, GameRandom& game, WatcomRandom& rand) {
previous = league;
const uint32_t count = uint32_t(kLeagueSizes[league]);
const uint32_t range = uint32_t(kLeagueStrength[league][1] - kLeagueStrength[league][0]);
const int level = int16_t(int((count - uint32_t(index)) * range * 100) / int(count) / 100) + kLeagueStrength[league][0];
const uint32_t place = ranked[size_t(team)] >= 0 ? uint32_t(ranked[size_t(team)]) : uint32_t(index);
const int level = int16_t(int((count - place) * range * 100) / int(count) / 100) + kLeagueStrength[league][0];
if (ranked[size_t(team)] >= 0) place_club(g, team, level, true);
const SquadRange r = squad_range(team);
for (size_t s = r.first; s < r.first + r.count; s++) {
const int id = g.squad_slots.at(s) & 0x0fff;
if (id != 0x0fff) modern::generate_player(g, id, level | 0x1000, game, rand);
if (id != 0x0fff && !keeps_world_values(g, id)) modern::generate_player(g, id, level | 0x1000, game, rand);
}
}
}
@@ -328,6 +411,11 @@ void set_club_strength(ModernState& g, int team, int mode, WatcomRandom& rand) {
default: break;
}
level = int16_t(level);
// Modern world: the squad moves to the level as a whole, its players keep their distances.
if (world_club(g, team)) {
place_club(g, team, level, false);
return;
}
const SquadRange r = squad_range(team);
for (size_t s = r.first; s < r.first + r.count; s++) {
const int id = g.squad_slots.at(s) & 0x0fff;
+7
View File
@@ -59,4 +59,11 @@ struct ModernState : GameState {
ModernState(const GameState& g) : GameState(g) { season_hooks = &modern::season_hooks(); }
};
// A player who came from the data set (not a new person the engine made of his index): his
// values are the data set's (docs/new_engine/balance.md). Without a world: nobody.
inline bool keeps_world_values(const ModernState& g, int player) {
return player >= 0 && size_t(player) < g.world_player_id.size() && !g.world_player_id[size_t(player)].empty() &&
!g.world_player_id[size_t(player)].starts_with("player:gen-");
}
} // namespace bmh::modern
+27
View File
@@ -11,6 +11,7 @@
// Usage: season_sim <BMH data dir> [turns=60] [master club=0] [watcom seed=1] [strength=2]
// Exit code: 0 no violation, 1 violations found, 2 the run stopped early (engine gap).
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
@@ -261,6 +262,32 @@ int main(int argc, char** argv) {
r.league_clubs, r.added_clubs, r.added_players, r.free_agents, r.fallback_nationalities, r.added_referees);
for (const auto& note : r.notes) std::printf(" league date moved: %s\n", note.c_str());
}
// MODERN_SPREAD=1: strength of every league club (mean of condition and technique of its
// best 14 players) per league at the career start, for the balance (balance.md)
if (std::getenv("MODERN_SPREAD") && modern::current_world()) {
const auto& st = session.state();
for (int league = 0; league < 9; ++league) {
std::vector<double> clubs;
const int first = league_first_team(league);
for (int t = first; t < first + int(kLeagueSizes[league]); ++t) {
std::vector<int> v;
const auto r = squad_range(t);
for (size_t s = r.first; s < r.first + r.count; ++s) {
const int id = st.squad_slots[s] & 0xfff;
if (id != 0xfff) v.push_back(st.players[size_t(id)].technique() + st.players[size_t(id)].condition());
}
std::sort(v.rbegin(), v.rend());
double sum = 0; int n = 0;
for (size_t i = 0; i < std::min<size_t>(14, v.size()); ++i) sum += v[i] / 2.0, ++n;
clubs.push_back(n ? sum / n : 0);
if (league < 2 && n && (sum / n < 60 || sum / n > 85)) std::printf("spread club %d %s %.1f (%d players)\n", t, st.world_club_name.size() > size_t(t) ? st.world_club_name[size_t(t)].c_str() : "?", sum / n, int(v.size()));
}
double mean = 0; for (double c : clubs) mean += c; mean /= double(clubs.size());
double var = 0; for (double c : clubs) var += (c - mean) * (c - mean); var /= double(clubs.size());
std::printf("spread league %d: club strength (best 14) mean %.1f sd %.1f min %.1f max %.1f\n", league, mean, std::sqrt(var),
*std::min_element(clubs.begin(), clubs.end()), *std::max_element(clubs.begin(), clubs.end()));
}
}
if (!session.confirm_manager(options, choice, error)) throw std::runtime_error("manager: " + error);
ui::CareerInitializationResult init;
if (!session.finish(init, error)) throw std::runtime_error("career start: " + error);