Player12
An open source football management simulator
Loading...
Searching...
No Matches
opposition_report.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 <array>
12#include <cstdint>
13#include <span>
14#include <string>
15#include <vector>
16
17#include "global/types.h"
19#include "model/match_report.h"
20#include "model/strategy.h"
21
23const char* oppositionInstructionKey(OppositionInstruction instruction);
24
32
40{
41 public:
43 void set(TeamID opponent, PlayerID player, OppositionInstruction instruction);
44 OppositionInstruction get(TeamID opponent, PlayerID player) const;
46 std::vector<OppositionOrder> forOpponent(TeamID opponent) const;
48 void clear(TeamID opponent);
49 const std::vector<OppositionOrder>& all() const { return orders; }
50 void restore(const std::vector<OppositionOrder>& restored);
51
52 private:
53 std::vector<OppositionOrder> orders;
54};
55
58{
60 std::string name;
62 bool likely_starter = false;
64 float estimate = -1.0f;
65 float knowledge = 0.0f;
66 bool right_footed = true;
67 int appearances = 0;
68 int goals = 0;
69 int assists = 0;
70 float average_rating = 0.0f;
71};
72
79
90
93{
96 std::span<const MatchReport> reports;
98 std::span<const MatchReport> league_reports;
99 std::vector<OppositionPlayer> squad;
100};
101
104{
105 float goals_for = 0.0f;
106 float goals_against = 0.0f;
107 float xg_for = 0.0f;
108 float xg_against = 0.0f;
109 float shots_for = 0.0f;
110 float shots_against = 0.0f;
111 float possession = 50.0f;
112 float pass_completion = 0.0f;
113 int matches = 0;
114};
115
118{
121 std::vector<int> form;
124 bool enough_data = false;
126 std::string formation;
127 std::vector<OppositionPlayer> likely_xi;
128 std::vector<KeyOpponent> key_players;
129 std::vector<AnalysisLine> strengths;
130 std::vector<AnalysisLine> weaknesses;
131 std::vector<CounterTactic> counters;
133 float confidence = 0.0f;
134};
135
137{
138inline constexpr std::size_t RECENT_MATCHES = 5;
139inline constexpr int MIN_MATCHES = 3;
140inline constexpr std::size_t KEY_PLAYERS = 3;
141inline constexpr std::size_t MAX_COUNTERS = 3;
143inline constexpr float HIGH_RATIO = 1.15f;
144inline constexpr float LOW_RATIO = 0.85f;
145inline constexpr float HIGH_POSSESSION = 55.0f;
146inline constexpr float LOW_POSSESSION = 45.0f;
148inline constexpr float PASSING_MARGIN = 4.0f;
150inline constexpr float MAIN_THREAT_SHARE = 0.4f;
152inline constexpr int MAIN_THREAT_MIN_GOALS = 5;
153} // namespace OppositionRules
154
156std::string formationLabel(std::span<const PlayerRole> starters);
157
160
162Strategy applyCounter(const Strategy& strategy, const CounterTactic& counter);
Instructions against upcoming opponents, per opponent and player (OppositionInstruction is declared i...
Definition opposition_report.h:40
const std::vector< OppositionOrder > & all() const
Definition opposition_report.h:49
OppositionInstruction get(TeamID opponent, PlayerID player) const
Definition opposition_report.cpp:119
std::vector< OppositionOrder > orders
Definition opposition_report.h:53
void set(TeamID opponent, PlayerID player, OppositionInstruction instruction)
Definition opposition_report.cpp:107
std::vector< OppositionOrder > forOpponent(TeamID opponent) const
Definition opposition_report.cpp:129
void clear(TeamID opponent)
Definition opposition_report.cpp:137
void restore(const std::vector< OppositionOrder > &restored)
Definition opposition_report.cpp:143
Represents the tactical setup of a team for a match.
Definition strategy.h:61
Definition opposition_report.h:137
constexpr float PASSING_MARGIN
Definition opposition_report.h:148
constexpr int MAIN_THREAT_MIN_GOALS
Definition opposition_report.h:152
constexpr float HIGH_POSSESSION
Definition opposition_report.h:145
constexpr std::size_t KEY_PLAYERS
Definition opposition_report.h:140
constexpr float MAIN_THREAT_SHARE
Definition opposition_report.h:150
constexpr float LOW_POSSESSION
Definition opposition_report.h:146
constexpr int MIN_MATCHES
Definition opposition_report.h:139
constexpr float LOW_RATIO
Definition opposition_report.h:144
constexpr std::size_t RECENT_MATCHES
Definition opposition_report.h:138
constexpr float HIGH_RATIO
Definition opposition_report.h:143
constexpr std::size_t MAX_COUNTERS
Definition opposition_report.h:141
std::string formationLabel(std::span< const PlayerRole > starters)
Definition opposition_report.cpp:150
Strategy applyCounter(const Strategy &strategy, const CounterTactic &counter)
Definition opposition_report.cpp:353
OppositionReport buildOppositionReport(const OppositionInput &input)
Definition opposition_report.cpp:170
const char * oppositionInstructionKey(OppositionInstruction instruction)
Definition opposition_report.cpp:101
A localised line: key plus arguments ({0}, {1}...).
Definition match_analysis.h:116
A suggested adjustment of the managed tactic.
Definition opposition_report.h:82
PlayerID mark
Definition opposition_report.h:88
AnalysisLine action
Definition opposition_report.h:83
AnalysisLine reason
Definition opposition_report.h:84
StrategySliders shift
Definition opposition_report.h:86
A key player with the reason he stands out.
Definition opposition_report.h:75
AnalysisLine reason
Definition opposition_report.h:77
OppositionPlayer player
Definition opposition_report.h:76
Per-match averages of a side.
Definition opposition_report.h:104
int matches
Definition opposition_report.h:113
float possession
Definition opposition_report.h:111
float goals_for
Definition opposition_report.h:105
float goals_against
Definition opposition_report.h:106
float pass_completion
Definition opposition_report.h:112
float xg_for
Definition opposition_report.h:107
float xg_against
Definition opposition_report.h:108
float shots_against
Definition opposition_report.h:110
float shots_for
Definition opposition_report.h:109
Facts gathered for the opposition report.
Definition opposition_report.h:93
std::span< const MatchReport > league_reports
Definition opposition_report.h:98
std::span< const MatchReport > reports
Definition opposition_report.h:96
TeamID opponent
Definition opposition_report.h:94
std::vector< OppositionPlayer > squad
Definition opposition_report.h:99
An instruction stored for the next match against a club.
Definition opposition_report.h:27
OppositionInstruction instruction
Definition opposition_report.h:30
PlayerID player
Definition opposition_report.h:29
TeamID opponent
Definition opposition_report.h:28
What the report knows about one opposing player.
Definition opposition_report.h:58
float knowledge
Definition opposition_report.h:65
bool likely_starter
Definition opposition_report.h:62
int appearances
Definition opposition_report.h:67
PlayerID player
Definition opposition_report.h:59
float estimate
Definition opposition_report.h:64
int assists
Definition opposition_report.h:69
std::string name
Definition opposition_report.h:60
PlayerRole role
Definition opposition_report.h:61
int goals
Definition opposition_report.h:68
bool right_footed
Definition opposition_report.h:66
float average_rating
Definition opposition_report.h:70
The pre-match opposition report.
Definition opposition_report.h:118
OppositionAverages league
Definition opposition_report.h:123
std::vector< AnalysisLine > strengths
Definition opposition_report.h:129
std::vector< CounterTactic > counters
Definition opposition_report.h:131
float confidence
Definition opposition_report.h:133
bool enough_data
Definition opposition_report.h:124
OppositionAverages recent
Definition opposition_report.h:122
std::vector< int > form
Definition opposition_report.h:121
TeamID opponent
Definition opposition_report.h:119
std::string formation
Definition opposition_report.h:126
std::vector< OppositionPlayer > likely_xi
Definition opposition_report.h:127
std::vector< AnalysisLine > weaknesses
Definition opposition_report.h:130
std::vector< KeyOpponent > key_players
Definition opposition_report.h:128
Team-wide tactical preferences in [0, 1].
Definition strategy.h:27
OppositionInstruction
Individual instruction against one opposing player (values are persisted in OppositionInstructions; a...
Definition tactics.h:77
uint16_t TeamID
Type alias for Team identifiers.
Definition types.h:18
uint32_t PlayerID
Type alias for Player identifiers.
Definition types.h:21
PlayerRole
Represents a specific tactical role on the pitch.
Definition types.h:63