Player12
An open source football management simulator
Loading...
Searching...
No Matches
training.h File Reference

Weekly training microcycle, workload, individual focus and tactical familiarity. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "global/types.h"

Go to the source code of this file.

Classes

struct  TrainingSlot
 One day of the template. More...
 
struct  TacticSnapshot
 Strategy sliders and outfield shape the squad has drilled. More...
 
struct  TrainingDay
 What a club does on one calendar day. More...
 
struct  TeamTrainingPlan
 A club's schedule, familiarity and training load. More...
 
struct  PlayerTrainingState
 Individual focus and workload history of a player. More...
 
struct  TrainingAdvice
 One assistant recommendation as a language key plus arguments (formatted with formatLocalized()). More...
 
struct  AdviceInputs
 Squad facts the assistant bases the advice on. More...
 
class  TrainingRegistry
 Training plans of every club and training state of every player. More...
 

Namespaces

namespace  TrainingModel
 Pure training rules (no game state), unit tested in isolation.
 
namespace  TrainingSystem
 Training processing on the live world (called by WorldSimulation).
 

Typedefs

using Microcycle = std::array< TrainingSlot, MICROCYCLE_DAYS >
 
using TrainingSystem::FixtureOutlook = std::unordered_map< TeamID, std::uint8_t >
 

Enumerations

enum class  MicrocycleDay : std::uint8_t {
  MdPlus1 = 0 , MdPlus2 , MdMinus4 , MdMinus3 ,
  MdMinus2 , MdMinus1 , COUNT
}
 Training days between two matches of a one-match week. More...
 
enum class  SessionType : std::uint8_t {
  Rest = 0 , Recovery , Fitness , Technical ,
  Attacking , Defending , Tactical , MatchPrep ,
  COUNT
}
 Session content (values are persisted). More...
 
enum class  TrainingIntensity : std::uint8_t { Low = 0 , Normal , High , COUNT }
 Session or squad-wide intensity (values are persisted). More...
 
enum class  TrainingPreset : std::uint8_t {
  Balanced = 0 , Fitness , Attacking , Defending ,
  YouthDevelopment , Light , Custom , COUNT
}
 Schedule templates (values are persisted). More...
 
enum class  TrainingFocus : std::uint8_t {
  None = 0 , Physical , Attacking , Playmaking ,
  Defending , Goalkeeping , RetrainStriker , RetrainMidfielder ,
  RetrainDefender , COUNT
}
 Individual training focus of a player (values are persisted). More...
 
enum class  WorkloadRisk : std::uint8_t { Low , Moderate , High }
 Injury risk band from workload and freshness. More...
 
enum class  AdviceSeverity : std::uint8_t { Info , Suggestion , Warning }
 Severity of an assistant recommendation. More...
 

Functions

Microcycle TrainingModel::presetMicrocycle (TrainingPreset preset)
 
float TrainingModel::sessionLoad (TrainingSlot slot, TrainingIntensity squad_intensity)
 
float TrainingModel::balancedWeekLoad ()
 
float TrainingModel::typicalDailyLoad ()
 
float TrainingModel::sessionInjuryExposure (TrainingSlot slot, TrainingIntensity squad_intensity)
 
std::optional< MicrocycleDay > TrainingModel::dayFor (int days_since_last, int days_to_next, std::int32_t ordinal)
 
bool TrainingModel::isCongested (int days_since_last, int days_to_next)
 
TrainingDay TrainingModel::scheduleDay (const TeamTrainingPlan &plan, int days_since_last, int days_to_next, std::int32_t ordinal)
 
float TrainingModel::conditionDrain (float load, float stamina)
 
float TrainingModel::recoveryShare (SessionType session)
 
float TrainingModel::sharpnessGain (TrainingSlot slot)
 
float TrainingModel::workloadRatio (const PlayerTrainingState &state)
 
float TrainingModel::workloadRiskMultiplier (const PlayerTrainingState &state)
 
WorkloadRisk TrainingModel::workloadRisk (const PlayerTrainingState &state, float condition)
 
void TrainingModel::rollDay (PlayerTrainingState &state)
 
float TrainingModel::developmentMultiplier (const TeamTrainingPlan &plan, int age, float coaching_quality)
 
std::array< float, 9 > TrainingModel::scheduleAttributeMix (const TeamTrainingPlan &plan)
 
std::array< float, 9 > TrainingModel::focusAttributeMix (TrainingFocus focus, const StatsConfig &config)
 
const std::array< const char *, 9 > & TrainingModel::attributeNames ()
 
float TrainingModel::applyDirectedGrowth (Player &player, float growth, const TeamTrainingPlan &plan, TrainingFocus focus, const StatsConfig &config)
 
TacticSnapshot TrainingModel::snapshotOf (const Team &team)
 
float TrainingModel::familiarityLoss (const TacticSnapshot &before, const TacticSnapshot &after)
 
float TrainingModel::familiarityGain (TrainingSlot slot)
 
std::vector< TrainingAdvice > TrainingModel::advise (const AdviceInputs &inputs)
 
const char * TrainingModel::sessionKey (SessionType session)
 
const char * TrainingModel::intensityKey (TrainingIntensity intensity)
 
const char * TrainingModel::presetKey (TrainingPreset preset)
 
const char * TrainingModel::focusKey (TrainingFocus focus)
 
const char * TrainingModel::dayKey (MicrocycleDay day)
 
const char * TrainingModel::riskKey (WorkloadRisk risk)
 
void TrainingSystem::planDay (GameData &gamedata, std::int32_t ordinal, const FixtureOutlook *outlook, bool training_period)
 
void TrainingSystem::rollWorkloads (GameData &gamedata)
 
double TrainingSystem::trainPlayer (GameData &gamedata, Player &player, std::int32_t ordinal)
 
double TrainingSystem::recordMatchLoad (GameData &gamedata, const Player &player, std::uint8_t minutes)
 
void TrainingSystem::recordTeamMatch (GameData &gamedata, TeamID team_id, std::int32_t ordinal)
 
float TrainingSystem::trainingQuality (const GameData &gamedata, const Player &player)
 
float TrainingSystem::directGrowth (GameData &gamedata, Player &player, float growth)
 
void TrainingSystem::recordWeeklyGrowth (GameData &gamedata, PlayerID player_id, float delta)
 
void TrainingSystem::endWeek (GameData &gamedata)
 
AdviceInputs TrainingSystem::adviceInputs (const GameData &gamedata, TeamID team_id, int matches_next_week)
 
float TrainingSystem::tacticalFamiliarity (const GameData &gamedata, TeamID team_id)
 

Variables

constexpr std::size_t MICROCYCLE_DAYS
 
constexpr std::size_t SESSION_TYPE_COUNT
 
constexpr std::size_t TRAINING_FOCUS_COUNT
 
constexpr float TrainingModel::MATCH_LOAD = 1.8f
 

Detailed Description

Weekly training microcycle, workload, individual focus and tactical familiarity.

A club trains to a template of six days between two matches (MD+1 recovery, MD+2 off, MD-4 strength, MD-3 endurance, MD-2 speed/tactics, MD-1 activation; rules-regulations 5.1, world-realism 8). The template is mapped onto the real fixture list every day; weeks with two matches collapse to recovery and activation only when auto-adjust is on.

Effects (all bounded around the Balanced preset, which reproduces the calibrated world simulation):

  • Each session adds training load to a player's acute (7-day) and chronic (28-day) workload. Load spikes relative to recent history raise the injury hazard modestly (x1.0-1.5); a high chronic load is mildly protective (x0.9) (world-realism 2.6/9.2: no magic ratio).
  • Sessions drain condition, recovery and rest days speed recovery.
  • The week's volume, the preset mix and the staff scale the development rate (T = 0.7-1.3) and steer growth towards the drilled attributes.
  • Tactical and match-preparation sessions build familiarity with the current strategy and shape; changing either costs familiarity.

Typedef Documentation

◆ Microcycle

using Microcycle = std::array<TrainingSlot, MICROCYCLE_DAYS>

Enumeration Type Documentation

◆ AdviceSeverity

enum class AdviceSeverity : std::uint8_t
strong

Severity of an assistant recommendation.

Enumerator
Info 
Suggestion 
Warning 

◆ MicrocycleDay

enum class MicrocycleDay : std::uint8_t
strong

Training days between two matches of a one-match week.

Enumerator
MdPlus1 

Recovery for starters, compensation for the rest.

MdPlus2 

Usually off.

MdMinus4 

Strength / high intensity.

MdMinus3 

Endurance / volume.

MdMinus2 

Speed / tactics.

MdMinus1 

Activation and set pieces.

COUNT 

◆ SessionType

enum class SessionType : std::uint8_t
strong

Session content (values are persisted).

Enumerator
Rest 
Recovery 

Pool, bike, mobility.

Fitness 

Strength and conditioning.

Technical 

Ball work: passing, dribbling, handling.

Attacking 

Finishing and attacking movement.

Defending 

Defensive shape, duels and tackling.

Tactical 

Team shape and units (builds familiarity).

MatchPrep 

Opponent preparation, set pieces, activation.

COUNT 

◆ TrainingFocus

enum class TrainingFocus : std::uint8_t
strong

Individual training focus of a player (values are persisted).

Enumerator
None 
Physical 

Pace, physicality, stamina.

Attacking 

Shooting, dribbling.

Playmaking 

Passing, vision.

Defending 

Defending, physicality.

Goalkeeping 

Handling and positioning.

RetrainStriker 

Attributes of the striker role.

RetrainMidfielder 

Attributes of the midfield roles.

RetrainDefender 

Attributes of the defensive roles.

COUNT 

◆ TrainingIntensity

enum class TrainingIntensity : std::uint8_t
strong

Session or squad-wide intensity (values are persisted).

Enumerator
Low 
Normal 
High 
COUNT 

◆ TrainingPreset

enum class TrainingPreset : std::uint8_t
strong

Schedule templates (values are persisted).

Enumerator
Balanced 
Fitness 
Attacking 
Defending 
YouthDevelopment 

Technical emphasis, faster growth for <= 21s.

Light 

Low load for congested periods.

Custom 

A template edited by hand.

COUNT 

◆ WorkloadRisk

enum class WorkloadRisk : std::uint8_t
strong

Injury risk band from workload and freshness.

Enumerator
Low 
Moderate 
High 

Variable Documentation

◆ MICROCYCLE_DAYS

constexpr std::size_t MICROCYCLE_DAYS
inlineconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(MicrocycleDay::COUNT))

◆ SESSION_TYPE_COUNT

constexpr std::size_t SESSION_TYPE_COUNT
inlineconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(SessionType::COUNT))

◆ TRAINING_FOCUS_COUNT

constexpr std::size_t TRAINING_FOCUS_COUNT
inlineconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(TrainingFocus::COUNT))