Modern: national teams play with squads of their nationality (M9)

A Modern layout gives every national team after no_team 24 squad slots.
On each national team day, after the German nomination, the strongest fit
players of each nationality (quotas 3/5/7/5, the German strength measure)
fill its squad and get a computer line-up; a nation without a goalkeeper
or with fewer than 14 nominees keeps its drawn rating. The shared match
core asks fields_players() instead of 'league club or no_team', which is
the same set in Classic. National squads get no cards or injuries, their
players develop after the match like Germany's, and the almanac records
their line-ups.

Diamond data 1.5: 24 of 61 nations play with players. Classic regression
(game 1 and two-player) unchanged, Classic-data season identical, save
round trip identical, ctest passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-25 15:02:50 +01:00
1 parent 96e88c9579
commit 0f36b507d4
17 files changed
+154 -22

No files matched your search

+2 -2
View File
@@ -319,7 +319,7 @@ bool save_pitch_formation_source(GameState& g, int manager_slot, int runtime_clu
}
static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
if (team >= world_layout().league_teams && team != no_team()) return; // teams without squads
if (!fields_players(g, team)) return; // teams without players
if (g.lineups_frozen) return; // LineupRuntimeField (the season change)
const bool improve_from_reserves = (mode & 0x80) != 0;
mode &= 0x7F;
@@ -631,7 +631,7 @@ void quicksort_by_key(int16_t* items, uint32_t* keys, int count, bool ascending)
}
bool substitute(GameState& g, int team, int off, int mode, WatcomRandom& rand) {
if (!(team < world_layout().league_teams || team == no_team())) return false;
if (!fields_players(g, team)) return false;
const int manager = g.manager_of(team);
int used = g.team_flags.at(team) >> 5 & 7; // substitutions so far
if (mode == 10) {
+6 -5
View File
@@ -87,7 +87,7 @@ MinuteReport MatchEngine::minute(int minute, int last_minute, int stoppage) {
// Human teams use the places on their tactics board, also for the player's value.
int MatchEngine::pick_player(int team, int mode, int exclude, MinuteReport& report, int preset) {
mode &= 0x7F; // 0x80 = reuse the squad of the previous call, same team here
if (team >= world_layout().league_teams && team != no_team()) return 0xFFF; // clubs without squad: nobody, no draws
if (!fields_players(state, team)) return 0xFFF; // teams without players: nobody, no draws
SquadRange range = squad_range(team);
if (range.count == 0) return 0xFFF;
RatingContext ctx{state.chance_rain, state.chance_temperature};
@@ -531,6 +531,7 @@ ForcedMatchEvent MatchEngine::event_impl(MatchGroup& g, int m, int s, int minute
// Small-squad teams (id >= 90) only half of the time; teams without squads never. The
// national team (0x165, squad nominated on the national team days) only while manager
// slot 0 holds it (CupDraw_FormatError_RuntimeField2 == 0x165: a Bundestrainer's match).
// The squads of the other national teams (Modern) get no cards or injuries either.
if (!(team < 90 || rand.range(0, 1) == 0)) return result;
if (!(team < world_layout().league_teams || team == no_team())) return result;
if (team == no_team() && (state.manager_teams.empty() || state.manager_teams[0] != no_team())) return result;
@@ -953,7 +954,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
}
// Goalkeeper of the opponent: the player in squad slot 0 if the formation puts it in goal.
if (!reality_played && (opp_team < world_layout().first_foreign_cup() || opp_team == no_team())) {
if (!reality_played && (opp_team < world_layout().first_foreign_cup() || fields_players(state, opp_team))) {
int x = 0, y = 0;
state.formation_position(opp_team, 0, x, y);
if (x == 0 && y == 4) keeper = state.squad_slots.at(squad_range(opp_team).first) & 0x0FFF;
@@ -988,7 +989,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
deflected = game.range(0, 5) == 0;
}
if (kind == 0) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
if (team >= world_layout().first_foreign_cup() && !fields_players(state, team)) {
// clubs without squad: the attack rating (TeamRating, profile 3), drawn
RatingContext drawn;
drawn.rand = &rand;
@@ -998,7 +999,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
}
}
if (keeper == 0xFFF) {
if (opp_team >= world_layout().first_foreign_cup() && opp_team != no_team()) {
if (opp_team >= world_layout().first_foreign_cup() && !fields_players(state, opp_team)) {
// clubs without squad: the goalkeeping rating (profile 0), drawn
RatingContext drawn;
drawn.rand = &rand;
@@ -1205,7 +1206,7 @@ void MatchEngine::penalty_shootout(MatchGroup& g, int m, MinuteReport& report) {
const int side = order[k];
const int team = pair[side];
int player = 0xFFF;
if (team < world_layout().league_teams || team == no_team()) {
if (fields_players(state, team)) {
// a player who has not taken a penalty yet (after 100 tries the list restarts)
int tries = 0;
bool fresh;
+1 -1
View File
@@ -122,7 +122,7 @@ int human_correction(GameState& g, RatingContext& ctx, int manager, int rank, in
} // namespace
int team_rating(GameState& g, int team, const RatingProfile& profile, RatingContext& ctx, int* keeper) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
if (team >= world_layout().first_foreign_cup() && !fields_players(g, team)) {
// Clubs without squad: per group a random value around the level of the club
// (ForeignClubStrength bits 5-7 -> RatingRuntimeField2), +2 if the group's strength bit is set
// (bit 3, 3, 2, 1 for goal, defence, midfield, attack: RatingRuntimeField3) and a style
+10 -1
View File
@@ -157,11 +157,20 @@ SquadRange squad_range(int team) {
const WorldLayout& w = world_layout();
if (team == w.no_team()) return {w.pool_end, w.no_team_slots};
if (team >= 0 && team < w.league_teams) return {w.squad_start[size_t(team)], w.squad_size[size_t(team)]};
if (w.national_squad(team)) return {w.national_start + uint32_t(team - w.no_team() - 1) * w.national_slots, w.national_slots};
return {0, 0};
}
bool fields_players(const GameState& g, int team) {
const WorldLayout& w = world_layout();
if ((team >= 0 && team < w.league_teams) || team == w.no_team()) return true;
if (!w.national_squad(team)) return false;
const SquadRange r = squad_range(team);
return r.first < g.squad_slots.size() && (g.squad_slots[r.first] & 0x0FFF) != 0x0FFF;
}
TeamAverage team_average(const GameState& g, int team, uint16_t flags, WatcomRandom* rand) {
if (team >= world_layout().first_foreign_cup() && team != no_team()) {
if (team >= world_layout().first_foreign_cup() && !fields_players(g, team)) {
// TeamRating(team, profile 2 at layout field): a random value around the club's level
if (!rand) throw std::invalid_argument("team_average: a team without squad needs the Watcom generator");
RatingContext ctx;
+4
View File
@@ -255,6 +255,10 @@ struct SquadRange {
size_t count = 0;
};
SquadRange squad_range(int team);
// Whether the team plays with its players (squad, line-up, scorers) rather than with a drawn rating:
// the league clubs and no_team always; in Modern a national team once players are nominated into
// its squad (its first slot is taken). Classic: exactly the league clubs and no_team.
bool fields_players(const GameState& g, int team);
// Selection and value flags of team_average (the "param_2" of QuoteNationalFriendlyMatch).
namespace avg {
+7
View File
@@ -37,6 +37,9 @@ int WorldLayout::team_of_slot(int slot) const {
return int(it - squad_start.begin()) - 1;
}
if (uint32_t(slot) >= pool_end && uint32_t(slot) < pool_end + no_team_slots) return no_team();
if (national_slots != 0 && uint32_t(slot) >= national_start &&
uint32_t(slot) < national_start + uint32_t(national_teams - 1) * national_slots)
return no_team() + 1 + int((uint32_t(slot) - national_start) / national_slots);
return -1;
}
@@ -60,6 +63,10 @@ void set_world_layout(WorldLayout layout) {
layout.foreign_offers != layout.free_agents + 80 || layout.pool_end != layout.foreign_offers + 20 ||
layout.total_slots < layout.pool_end + layout.no_team_slots)
throw std::invalid_argument("world layout: pools must follow the squads");
if (layout.national_slots != 0 &&
(layout.national_start < layout.pool_end + layout.no_team_slots || layout.national_teams < 1 ||
layout.total_slots < layout.national_start + uint32_t(layout.national_teams - 1) * layout.national_slots))
throw std::invalid_argument("world layout: national squads must follow the no-club squad");
// Squad slot values hold 12-bit player ids; loans store 10-bit club ids.
if (layout.total_teams() > 1023) throw std::invalid_argument("world layout: too many teams");
current() = std::move(layout);
+11 -3
View File
@@ -38,14 +38,22 @@ struct WorldLayout {
uint32_t pool_end = 0xC00; // end of the pools = first slot of no_team
uint32_t no_team_slots = 24; // the national team / no-club squad
uint32_t total_slots = 3150; // including the reserve behind no_team
// Modern: squads of the national teams after no_team (national_slots each, from slot
// national_start: team no_team() + n at national_start + (n - 1) * national_slots). Classic: none,
// the national teams play without players.
uint32_t national_start = 0, national_slots = 0;
int first_amateur() const { return league_teams; }
int first_foreign_cup() const { return league_teams + amateur_teams; }
int no_team() const { return first_foreign_cup() + foreign_cup_teams; }
int total_teams() const { return no_team() + national_teams; }
bool has_squad(int team) const { return (team >= 0 && team < league_teams) || team == no_team(); }
// The team whose squad holds `slot`: a league club, no_team() for the no-club squad, -1 for
// the pools and the reserve.
// A national team other than no_team with squad slots of its own (Modern).
bool national_squad(int team) const { return national_slots != 0 && team > no_team() && team < total_teams(); }
bool has_squad(int team) const {
return (team >= 0 && team < league_teams) || team == no_team() || national_squad(team);
}
// The team whose squad holds `slot`: a league club, no_team() for the no-club squad, a
// national team for its squad, -1 for the pools and the reserve.
int team_of_slot(int slot) const;
};