Player12
An open source football management simulator
Loading...
Searching...
No Matches
tactics.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <cstdint>
12#include <span>
13#include <string_view>
14
15#include "global/types.h"
16
17class Lineup;
18class Player;
19class Strategy;
20
25enum class RoleFamily : std::uint8_t
26{
30 Holding,
31 Central,
33 Wide,
34 Striker,
35 COUNT
36};
37
62
64enum class RoleDuty : std::uint8_t
65{
66 Defend,
67 Support,
68 Attack,
69 COUNT
70};
71
76enum class OppositionInstruction : std::uint8_t
77{
78 None = 0,
79 TightMark,
80 Press,
82 DoubleUp,
83 COUNT
84};
85
92{
100 float runBias = 0.0f;
102 float overlapBias = 0.0f;
104 float passDaring = 0.0f;
106 float targetBias = 0.0f;
108 float pressBias = 0.0f;
110 float shotBias = 0.0f;
112 float cutInside = 0.0f;
114 float keeperDepthMetres = 0.0f;
116 float keeperSweep = 0.0f;
117};
118
133
140
142enum class PossessionShape : std::uint8_t
143{
144 KeepShape,
148 COUNT
149};
150
153{
155inline constexpr float SLOT_MATCH_DISTANCE = 0.06f;
156inline constexpr float RUN_BIAS_WEIGHT = 0.22f;
157inline constexpr float OVERLAP_BIAS_WEIGHT = 0.25f;
158inline constexpr float PRESS_BIAS_SECONDS = 0.6f;
159inline constexpr float PASS_DARING_PROGRESS_WEIGHT = 3.0f;
160inline constexpr float PASS_DARING_SAFETY_WEIGHT = 1.0f;
161inline constexpr float TARGET_BIAS_WEIGHT = 1.0f;
162inline constexpr float SHOT_BIAS_WEIGHT = 2.0f;
163inline constexpr float CUT_INSIDE_SHIFT = 0.9f;
164inline constexpr float KEEPER_SWEEP_DEPTH_GAIN = 0.5f;
165inline constexpr float KEEPER_SWEEP_ADVANTAGE_GAIN = 0.15f;
167inline constexpr float PRESS_BIAS_ENGAGE = 0.35f;
168
170inline constexpr float TIGHT_MARK_WEIGHT = 0.88f;
171inline constexpr float TIGHT_MARK_GOAL_SIDE_METRES = 1.2f;
173inline constexpr float TIGHT_MARK_REACH_METRES = 3.0f;
174inline constexpr float TIGHT_MARK_COMPLETION_PENALTY = 0.10f;
176inline constexpr float PRESS_ORDER_STANDOFF_SHARE = 0.45f;
177inline constexpr float PRESS_ORDER_ENGAGE = 0.8f;
180inline constexpr float WEAK_FOOT_SHADE_METRES = 1.5f;
181inline constexpr float WEAK_FOOT_ERROR_GAIN = 0.45f;
182inline constexpr float WEAK_FOOT_SHOT_PENALTY = 0.35f;
184inline constexpr float DOUBLE_UP_SUPPORT_METRES = 2.5f;
185inline constexpr float DOUBLE_UP_ENGAGE = 0.4f;
186inline constexpr float DOUBLE_UP_TAKE_ON_PENALTY = 0.12f;
187inline constexpr float DOUBLE_UP_REACH_METRES = 5.0f;
188
191inline constexpr float TALK_FULL_MINUTES = 10.0f;
192inline constexpr float TALK_FADE_END_MINUTES = 20.0f;
193inline constexpr float TALK_REFERENCE = 0.012f;
195inline constexpr float TALK_COMPOSURE = 0.25f;
196inline constexpr float TALK_PRESS_SECONDS = 0.3f;
197inline constexpr float TALK_ENGAGE = 0.25f;
198} // namespace TacticsTuning
199
204namespace Tactics
205{
208
210std::span<const TacticalRole> rolesFor(RoleFamily family);
211
213bool allows(RoleFamily family, TacticalRole role);
214
216bool hasDuty(RoleFamily family);
217
220
222const char* familyKey(RoleFamily family);
223const char* roleKey(TacticalRole role);
224const char* roleDescriptionKey(TacticalRole role);
225const char* dutyKey(RoleDuty duty);
226const char* possessionShapeKey(PossessionShape shape);
227
232std::span<const std::string_view> keyAttributes(RoleFamily family,
233 TacticalRole role);
234
239float roleFit(const Player& player, RoleFamily family, TacticalRole role);
240
242RoleDuty suggestedDuty(const Player& player, RoleFamily family);
243
248TacticalRole suggestedRole(const Player& player, RoleFamily family);
249
252
257void assignRolesToFit(Strategy& strategy, const Lineup& lineup);
258} // namespace Tactics
Manages the starting XI and reserves of a team.
Definition lineup.h:85
Persistent career identity, attributes, traits and day-to-day state.
Definition player.h:104
Represents the tactical setup of a team for a match.
Definition strategy.h:61
Definition tactics.h:153
constexpr float PRESS_ORDER_STANDOFF_SHARE
Definition tactics.h:176
constexpr float CUT_INSIDE_SHIFT
Definition tactics.h:163
constexpr float DOUBLE_UP_ENGAGE
Definition tactics.h:185
constexpr float PASS_DARING_PROGRESS_WEIGHT
Definition tactics.h:159
constexpr float WEAK_FOOT_SHOT_PENALTY
Definition tactics.h:182
constexpr float RUN_BIAS_WEIGHT
Definition tactics.h:156
constexpr float TARGET_BIAS_WEIGHT
Definition tactics.h:161
constexpr float PASS_DARING_SAFETY_WEIGHT
Definition tactics.h:160
constexpr float PRESS_BIAS_SECONDS
Definition tactics.h:158
constexpr float KEEPER_SWEEP_ADVANTAGE_GAIN
Definition tactics.h:165
constexpr float TALK_FULL_MINUTES
Definition tactics.h:191
constexpr float TIGHT_MARK_REACH_METRES
Definition tactics.h:173
constexpr float TIGHT_MARK_COMPLETION_PENALTY
Definition tactics.h:174
constexpr float TALK_FADE_END_MINUTES
Definition tactics.h:192
constexpr float TIGHT_MARK_WEIGHT
Definition tactics.h:170
constexpr float PRESS_ORDER_ENGAGE
Definition tactics.h:177
constexpr float DOUBLE_UP_SUPPORT_METRES
Definition tactics.h:184
constexpr float DOUBLE_UP_REACH_METRES
Definition tactics.h:187
constexpr float WEAK_FOOT_SHADE_METRES
Definition tactics.h:180
constexpr float DOUBLE_UP_TAKE_ON_PENALTY
Definition tactics.h:186
constexpr float TALK_COMPOSURE
Definition tactics.h:195
constexpr float SLOT_MATCH_DISTANCE
Definition tactics.h:155
constexpr float KEEPER_SWEEP_DEPTH_GAIN
Definition tactics.h:164
constexpr float TALK_ENGAGE
Definition tactics.h:197
constexpr float TIGHT_MARK_GOAL_SIDE_METRES
Definition tactics.h:171
constexpr float OVERLAP_BIAS_WEIGHT
Definition tactics.h:157
constexpr float SHOT_BIAS_WEIGHT
Definition tactics.h:162
constexpr float WEAK_FOOT_ERROR_GAIN
Definition tactics.h:181
constexpr float PRESS_BIAS_ENGAGE
Definition tactics.h:167
constexpr float TALK_PRESS_SECONDS
Definition tactics.h:196
constexpr float TALK_REFERENCE
Definition tactics.h:193
Roles, duties, in-possession shapes and their engine profiles. Pure functions; the tactic data itself...
Definition tactics.cpp:166
const char * roleKey(TacticalRole role)
Definition tactics.cpp:344
const char * familyKey(RoleFamily family)
Definition tactics.cpp:338
RoleDuty suggestedDuty(const Player &player, RoleFamily family)
Definition tactics.cpp:444
const char * roleDescriptionKey(TacticalRole role)
Definition tactics.cpp:349
const char * possessionShapeKey(PossessionShape shape)
Definition tactics.cpp:360
void assignRolesToFit(Strategy &strategy, const Lineup &lineup)
Definition tactics.cpp:505
TacticalRole suggestedRole(const Player &player, RoleFamily family)
Definition tactics.cpp:456
std::span< const std::string_view > keyAttributes(RoleFamily family, TacticalRole role)
Definition tactics.cpp:365
RoleFamily familyForSlot(Vector2F anchor)
Definition tactics.cpp:167
Vector2F possessionOffset(PossessionShape shape, Vector2F anchor)
Definition tactics.cpp:473
std::span< const TacticalRole > rolesFor(RoleFamily family)
Definition tactics.cpp:179
float roleFit(const Player &player, RoleFamily family, TacticalRole role)
Definition tactics.cpp:428
const char * dutyKey(RoleDuty duty)
Definition tactics.cpp:355
bool allows(RoleFamily family, TacticalRole role)
Definition tactics.cpp:205
bool hasDuty(RoleFamily family)
Definition tactics.cpp:210
RoleProfile profile(TacticalRole role, RoleDuty duty)
Definition tactics.cpp:212
An instruction against an opposing player for the next match.
Definition tactics.h:136
PlayerID player
Definition tactics.h:137
OppositionInstruction instruction
Definition tactics.h:138
Measurable behaviour of a role and duty in the match engine. Distances are metres,...
Definition tactics.h:92
float passDaring
Definition tactics.h:104
float runBias
Definition tactics.h:100
float possessionWidthMetres
Definition tactics.h:96
float overlapBias
Definition tactics.h:102
float cutInside
Definition tactics.h:112
float keeperDepthMetres
Definition tactics.h:114
float shotBias
Definition tactics.h:110
float defensiveAdvanceMetres
Definition tactics.h:98
float pressBias
Definition tactics.h:108
float targetBias
Definition tactics.h:106
float possessionAdvanceMetres
Definition tactics.h:94
float keeperSweep
Definition tactics.h:116
Role, duty and in-possession spot of one outfield slot. Slots are matched by their out-of-possession ...
Definition tactics.h:126
Vector2F anchor
Definition tactics.h:127
RoleDuty duty
Definition tactics.h:129
Vector2F possessionOffset
Definition tactics.h:131
TacticalRole role
Definition tactics.h:128
A simple 2D float vector for pitch coordinates.
Definition types.h:84
OppositionInstruction
Individual instruction against one opposing player (values are persisted in OppositionInstructions; a...
Definition tactics.h:77
RoleDuty
Attacking commitment of a role (persisted in the tactic).
Definition tactics.h:65
TacticalRole
How a player interprets his slot (values are persisted in the tactic). Standard plays the position as...
Definition tactics.h:43
RoleFamily
Position group of a formation slot; it decides which roles the slot can be given (see Tactics::family...
Definition tactics.h:26
PossessionShape
Ready-made in-possession shapes offered on the tactics screen.
Definition tactics.h:143
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21