|
Player12
An open source football management simulator
|
Recruitment under uncertainty for the managed club. More...
#include <scouting.h>
Classes | |
| struct | Estimate |
| struct | Noise |
Public Types | |
| using | ScoutProvider = std::function< std::vector< ScoutProfile >(TeamID)> |
| using | BudgetProvider = std::function< std::int64_t(TeamID)> |
Public Member Functions | |
| ScoutingSystem (std::shared_ptr< GameData > gamedata) | |
| void | setScoutProvider (ScoutProvider provider) |
| void | setBudgetProvider (BudgetProvider provider) |
| void | setManagedTeam (TeamID team_id) |
| TeamID | getManagedTeam () const |
| void | onDayAdvanced (const GameDateValue &date, Inbox &inbox) |
| void | invalidatePriors () const |
| void | onManagedMatch (TeamID opponent_id) |
| float | knowledgeOf (PlayerID player_id) const |
| float | baselineKnowledge (const Player &player) const |
| void | observe (PlayerID player_id, float amount, const ScoutProfile *scout) |
| std::optional< ScoutedPlayerView > | view (PlayerID player_id) const |
| std::optional< ScoutedPlayerRow > | row (PlayerID player_id) const |
| std::vector< ScoutedPlayerRow > | search (const ScoutSearchFilter &filter) const |
| std::vector< ScoutProfile > | getScouts () const |
| const std::vector< ScoutAssignment > & | getAssignments () const |
| const ScoutAssignment * | activeAssignment (std::uint32_t scout_id) const |
| ScoutStatus | scoutStatus (std::uint32_t scout_id) const |
| std::vector< ScoutSummary > | scoutSummaries () const |
| ScoutExpertise | expertiseOf (std::uint32_t scout_id) const |
| ScoutEffectiveness | effectiveness (std::uint32_t scout_id, ScoutTargetKind kind, std::uint32_t target_id) const |
| LeagueID | countryOf (LeagueID league_id) const |
| std::int64_t | assignmentCost (ScoutTargetKind kind, std::uint32_t target_id, std::uint16_t days) const |
| ScoutAssignError | startAssignment (const GameDateValue &date, std::uint32_t scout_id, ScoutTargetKind kind, std::uint32_t target_id, std::uint16_t days) |
| bool | cancelAssignment (std::uint32_t assignment_id) |
| const std::vector< ScoutReport > & | getReports () const |
| std::size_t | unreadReports () const |
| std::size_t | unreadReports (std::uint32_t scout_id) const |
| bool | markReportsSeen (std::uint32_t scout_id) |
| const std::vector< RecruitmentFocus > & | getFocuses () const |
| std::uint32_t | upsertFocus (RecruitmentFocus focus) |
| bool | removeFocus (std::uint32_t focus_id) |
| const std::vector< ShortlistEntry > & | getShortlist () const |
| bool | isShortlisted (PlayerID player_id) const |
| bool | addToShortlist (const GameDateValue &date, PlayerID player_id) |
| bool | removeFromShortlist (PlayerID player_id) |
| std::vector< SquadComparisonRow > | compareWithSquad () const |
| const ScoutingState & | getState () const |
| void | restore (ScoutingState restored) |
Static Public Member Functions | |
| static std::vector< ScoutProfile > | defaultScouts (const GameData &gamedata, TeamID team_id) |
| static bool | matchesFocus (const RecruitmentFocus &focus, const ScoutedPlayerRow &row) |
Static Public Attributes | |
| static constexpr std::size_t | ROLE_COUNT |
Private Types | |
| using | TeamPrior = std::array< std::vector< float >, POSITION_GROUPS > |
Private Member Functions | |
| float | priorMean (TeamID team_id, std::size_t group, std::size_t index) const |
| Estimate | estimateStat (const Player &player, const std::string &stat, float value, float noise_sd) const |
| std::pair< float, float > | departmentJudging () const |
| Noise | noiseFor (const Player &player, float knowledge) const |
| float | standardNormal (PlayerID player_id, std::uint64_t key) const |
| const RoleFocus * | focusFor (PlayerRole role) const |
| float | estimatedOverall (const Player &player, float attribute_sd, float *overall_sd) const |
| ScoutedPlayerRow | makeRow (const Player &player) const |
| std::int64_t | estimatedFee (const Player &player, const ScoutedPlayerRow &row) const |
| bool | anyFocusMatches (const ScoutedPlayerRow &row) const |
| std::vector< LeagueID > | worldCountries () const |
| void | ensureExpertise () |
| std::vector< TargetCountry > | targetCountries (const ScoutExpertise &expertise, ScoutTargetKind kind, std::uint32_t target_id, LeagueID *league) const |
| void | addExperience (std::uint32_t scout_id, LeagueID league_id) |
| bool | isForeign (const Player &player) const |
| bool | isForeignTarget (ScoutTargetKind kind, std::uint32_t target_id) const |
| const ScoutProfile * | findScout (std::uint32_t scout_id) const |
| void | refreshScouts () const |
| void | progressAssignment (ScoutAssignment &assignment, const GameDateValue &date, std::int32_t ordinal, Inbox &inbox) |
| void | coverageDay (ScoutAssignment &assignment, const ScoutProfile &scout, const GameDateValue &date, std::int32_t ordinal, Inbox &inbox) |
| std::vector< PlayerID > | coverage (const ScoutAssignment &assignment) const |
| const ScoutReport & | fileReport (const GameDateValue &date, const Player &player, const ScoutProfile &scout, std::int32_t ordinal, std::uint32_t assignment_id) |
| void | finishAssignment (ScoutAssignment &assignment, const GameDateValue &date, Inbox &inbox) |
| void | checkShortlist (const GameDateValue &date, Inbox &inbox) |
| void | pruneHistory () |
| std::uint8_t | shortlistFlags (const Player &player) const |
| std::array< float, ROLE_COUNT > | ownBestByRole () const |
Static Private Member Functions | |
| static std::int64_t | estimatedValue (const Player &player, float estimated_overall, float estimated_potential) |
| static ScoutProfile | effectiveScout (const ScoutProfile &scout, float multiplier) |
Private Attributes | |
| std::shared_ptr< GameData > | gamedata |
| ScoutProvider | scout_provider |
| BudgetProvider | budget_provider |
| std::recursive_mutex | cache_mutex |
| std::vector< ScoutProfile > | scouts |
| std::unordered_map< TeamID, TeamPrior > | priors |
| std::unordered_map< std::uint32_t, ScoutExpertise > | generated |
| ScoutingState | state |
Static Private Attributes | |
| static constexpr std::size_t | POSITION_GROUPS = 4 |
Recruitment under uncertainty for the managed club.
Every (club, player) pair has a knowledge level: a baseline from the relation (own squad, same league, same country, abroad) plus what scouts and matches added, decaying slowly back to the baseline. A scout observes the truth plus a fixed standard-normal offset per (club, player, attribute) scaled by a noise that shrinks with knowledge and his judging; the displayed estimate regresses that observation towards what is typical for the player's position at his club (normal-prior shrinkage), so estimates converge towards the truth, never flicker, and poorly known players do not top rankings through noise alone. Scouts are sent on paid assignments (a player, a league, a country, a continent or the free-agent pool) and perform according to their regional expertise (home country, languages, experience; see ScoutExpertiseModel); they file graded reports and prioritise the club's recruitment focuses. Shortlisted players raise alerts when they are listed, enter their final contract year, get injured or move. Const cache lookups may run concurrently; returned scout lists are snapshots. Career mutations and borrowed assignment/state references require exclusive access to the underlying career, including its GameData.
| using ScoutingSystem::BudgetProvider = std::function<std::int64_t(TeamID)> |
| using ScoutingSystem::ScoutProvider = std::function<std::vector<ScoutProfile>(TeamID)> |
|
private |
Mean attributes per position group of a club (possible_stats order).
|
explicit |
| const ScoutAssignment * ScoutingSystem::activeAssignment | ( | std::uint32_t | scout_id | ) | const |
Active assignment of a scout, if any.
|
private |
| bool ScoutingSystem::addToShortlist | ( | const GameDateValue & | date, |
| PlayerID | player_id | ||
| ) |
|
private |
| std::int64_t ScoutingSystem::assignmentCost | ( | ScoutTargetKind | kind, |
| std::uint32_t | target_id, | ||
| std::uint16_t | days | ||
| ) | const |
Price of an assignment (0 if the target is invalid).
| float ScoutingSystem::baselineKnowledge | ( | const Player & | player | ) | const |
Knowledge without any scouting (relation to the managed club).
| bool ScoutingSystem::cancelAssignment | ( | std::uint32_t | assignment_id | ) |
Recalls a scout; travel is booked in advance, so nothing is refunded.
|
private |
| std::vector< SquadComparisonRow > ScoutingSystem::compareWithSquad | ( | ) | const |
Own depth per position against the best shortlisted estimate.
|
private |
|
private |
|
static |
The club's scouts: its Scout staff (judging ability and potential from the staff attributes). Worlds without a staff roster fall back to scouts derived from the club's reputation and the world seed.
|
private |
Mean judging (ability, potential) of the club's scouts.
| ScoutEffectiveness ScoutingSystem::effectiveness | ( | std::uint32_t | scout_id, |
| ScoutTargetKind | kind, | ||
| std::uint32_t | target_id | ||
| ) | const |
Expected effectiveness of sending a scout to a target (0.6x-1.5x).
|
staticprivate |
The scout as he performs with multiplier (sharper or blunter).
|
private |
Stores the generated background of scouts seen for the first time.
|
private |
|
private |
|
staticprivate |
|
private |
| ScoutExpertise ScoutingSystem::expertiseOf | ( | std::uint32_t | scout_id | ) | const |
Background, languages and experience of a scout.
|
private |
|
private |
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
| std::vector< ScoutProfile > ScoutingSystem::getScouts | ( | ) | const |
Current scouts (re-read from the staff roster on each call).
|
inline |
|
inline |
|
inline |
Drops the cached squad priors (squads or attributes changed), so estimates match what a reloaded save computes.
|
private |
|
private |
| bool ScoutingSystem::isShortlisted | ( | PlayerID | player_id | ) | const |
| float ScoutingSystem::knowledgeOf | ( | PlayerID | player_id | ) | const |
Effective knowledge 0-100 of a player.
|
private |
| bool ScoutingSystem::markReportsSeen | ( | std::uint32_t | scout_id | ) |
Marks a scout's reports as opened; false if none were unread.
|
static |
True if the estimated row satisfies focus.
|
private |
| void ScoutingSystem::observe | ( | PlayerID | player_id, |
| float | amount, | ||
| const ScoutProfile * | scout | ||
| ) |
Adds observation (diminishing returns towards the cap).
| void ScoutingSystem::onDayAdvanced | ( | const GameDateValue & | date, |
| Inbox & | inbox | ||
| ) |
Assignment progress, knowledge decay and shortlist alerts.
| void ScoutingSystem::onManagedMatch | ( | TeamID | opponent_id | ) |
The managed club faced opponent_id: its players become known.
|
private |
Best own overall per PlayerRole index (0 = none).
|
private |
|
private |
|
private |
|
private |
| bool ScoutingSystem::removeFocus | ( | std::uint32_t | focus_id | ) |
| bool ScoutingSystem::removeFromShortlist | ( | PlayerID | player_id | ) |
| void ScoutingSystem::restore | ( | ScoutingState | restored | ) |
| std::optional< ScoutedPlayerRow > ScoutingSystem::row | ( | PlayerID | player_id | ) | const |
Estimated overall and potential range without attribute detail.
| ScoutStatus ScoutingSystem::scoutStatus | ( | std::uint32_t | scout_id | ) | const |
What a scout is doing (drives the scout page).
| std::vector< ScoutSummary > ScoutingSystem::scoutSummaries | ( | ) | const |
Every scout with his status and report counters, in roster order.
| std::vector< ScoutedPlayerRow > ScoutingSystem::search | ( | const ScoutSearchFilter & | filter | ) | const |
Search on estimated values, best estimated overall first.
| void ScoutingSystem::setBudgetProvider | ( | BudgetProvider | provider | ) |
Replaces the source of the transfer money a club can commit, used to grade reports as affordable. Without it the board's allowance capped by the club's spare cash (ClubEconomy::availableTransferBudget) is used.
| void ScoutingSystem::setManagedTeam | ( | TeamID | team_id | ) |
Binds the department to the managed club; a new club starts afresh.
| void ScoutingSystem::setScoutProvider | ( | ScoutProvider | provider | ) |
Replaces the source of the club's scouts. Without it the club's staff members in the Scout role are used (see defaultScouts()).
|
private |
|
private |
| ScoutAssignError ScoutingSystem::startAssignment | ( | const GameDateValue & | date, |
| std::uint32_t | scout_id, | ||
| ScoutTargetKind | kind, | ||
| std::uint32_t | target_id, | ||
| std::uint16_t | days | ||
| ) |
Starts an assignment and books its cost on date.
|
private |
Countries of an assignment with their weights, plus its league.
| std::size_t ScoutingSystem::unreadReports | ( | ) | const |
Reports not yet opened, of every scout or of one.
| std::size_t ScoutingSystem::unreadReports | ( | std::uint32_t | scout_id | ) | const |
| std::uint32_t ScoutingSystem::upsertFocus | ( | RecruitmentFocus | focus | ) |
Adds (id 0) or updates a focus; returns its id, 0 if full/invalid.
| std::optional< ScoutedPlayerView > ScoutingSystem::view | ( | PlayerID | player_id | ) | const |
Estimated view of a player; nullopt if unknown.
|
private |
|
private |
|
mutableprivate |
Cache lookups call one another while building summaries and estimates.
|
private |
|
mutableprivate |
Backgrounds of scouts not stored yet (identical once stored).
|
staticconstexprprivate |
|
staticconstexpr |
|
private |
|
mutableprivate |
Cache of the provider.
|
private |