Player12
An open source football management simulator
Loading...
Searching...
No Matches
ScoutingSystem Class Reference

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
 

Detailed Description

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.

Member Typedef Documentation

◆ BudgetProvider

using ScoutingSystem::BudgetProvider = std::function<std::int64_t(TeamID)>

◆ ScoutProvider

using ScoutingSystem::ScoutProvider = std::function<std::vector<ScoutProfile>(TeamID)>

◆ TeamPrior

using ScoutingSystem::TeamPrior = std::array<std::vector<float>, POSITION_GROUPS>
private

Mean attributes per position group of a club (possible_stats order).

Constructor & Destructor Documentation

◆ ScoutingSystem()

ScoutingSystem::ScoutingSystem ( std::shared_ptr< GameData >  gamedata)
explicit

Member Function Documentation

◆ activeAssignment()

const ScoutAssignment * ScoutingSystem::activeAssignment ( std::uint32_t  scout_id) const

Active assignment of a scout, if any.

◆ addExperience()

void ScoutingSystem::addExperience ( std::uint32_t  scout_id,
LeagueID  league_id 
)
private

◆ addToShortlist()

bool ScoutingSystem::addToShortlist ( const GameDateValue &  date,
PlayerID  player_id 
)

◆ anyFocusMatches()

bool ScoutingSystem::anyFocusMatches ( const ScoutedPlayerRow &  row) const
private

◆ assignmentCost()

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).

◆ baselineKnowledge()

float ScoutingSystem::baselineKnowledge ( const Player &  player) const

Knowledge without any scouting (relation to the managed club).

◆ cancelAssignment()

bool ScoutingSystem::cancelAssignment ( std::uint32_t  assignment_id)

Recalls a scout; travel is booked in advance, so nothing is refunded.

◆ checkShortlist()

void ScoutingSystem::checkShortlist ( const GameDateValue &  date,
Inbox &  inbox 
)
private

◆ compareWithSquad()

std::vector< SquadComparisonRow > ScoutingSystem::compareWithSquad ( ) const

Own depth per position against the best shortlisted estimate.

◆ countryOf()

LeagueID ScoutingSystem::countryOf ( LeagueID  league_id) const

Top league (country) of a league.

◆ coverage()

std::vector< PlayerID > ScoutingSystem::coverage ( const ScoutAssignment &  assignment) const
private

◆ coverageDay()

void ScoutingSystem::coverageDay ( ScoutAssignment &  assignment,
const ScoutProfile &  scout,
const GameDateValue &  date,
std::int32_t  ordinal,
Inbox &  inbox 
)
private

◆ defaultScouts()

std::vector< ScoutProfile > ScoutingSystem::defaultScouts ( const GameData &  gamedata,
TeamID  team_id 
)
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.

◆ departmentJudging()

std::pair< float, float > ScoutingSystem::departmentJudging ( ) const
private

Mean judging (ability, potential) of the club's scouts.

◆ effectiveness()

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).

◆ effectiveScout()

ScoutProfile ScoutingSystem::effectiveScout ( const ScoutProfile &  scout,
float  multiplier 
)
staticprivate

The scout as he performs with multiplier (sharper or blunter).

◆ ensureExpertise()

void ScoutingSystem::ensureExpertise ( )
private

Stores the generated background of scouts seen for the first time.

◆ estimatedFee()

std::int64_t ScoutingSystem::estimatedFee ( const Player &  player,
const ScoutedPlayerRow &  row 
) const
private

◆ estimatedOverall()

float ScoutingSystem::estimatedOverall ( const Player &  player,
float  attribute_sd,
float *  overall_sd 
) const
private

◆ estimatedValue()

std::int64_t ScoutingSystem::estimatedValue ( const Player &  player,
float  estimated_overall,
float  estimated_potential 
)
staticprivate

◆ estimateStat()

ScoutingSystem::Estimate ScoutingSystem::estimateStat ( const Player &  player,
const std::string &  stat,
float  value,
float  noise_sd 
) const
private

◆ expertiseOf()

ScoutExpertise ScoutingSystem::expertiseOf ( std::uint32_t  scout_id) const

Background, languages and experience of a scout.

◆ fileReport()

const ScoutReport & ScoutingSystem::fileReport ( const GameDateValue &  date,
const Player &  player,
const ScoutProfile &  scout,
std::int32_t  ordinal,
std::uint32_t  assignment_id 
)
private

◆ findScout()

const ScoutProfile * ScoutingSystem::findScout ( std::uint32_t  scout_id) const
private

◆ finishAssignment()

void ScoutingSystem::finishAssignment ( ScoutAssignment &  assignment,
const GameDateValue &  date,
Inbox &  inbox 
)
private

◆ focusFor()

const RoleFocus * ScoutingSystem::focusFor ( PlayerRole  role) const
private

◆ getAssignments()

const std::vector< ScoutAssignment > & ScoutingSystem::getAssignments ( ) const
inline

◆ getFocuses()

const std::vector< RecruitmentFocus > & ScoutingSystem::getFocuses ( ) const
inline

◆ getManagedTeam()

TeamID ScoutingSystem::getManagedTeam ( ) const
inline

◆ getReports()

const std::vector< ScoutReport > & ScoutingSystem::getReports ( ) const
inline

◆ getScouts()

std::vector< ScoutProfile > ScoutingSystem::getScouts ( ) const

Current scouts (re-read from the staff roster on each call).

◆ getShortlist()

const std::vector< ShortlistEntry > & ScoutingSystem::getShortlist ( ) const
inline

◆ getState()

const ScoutingState & ScoutingSystem::getState ( ) const
inline

◆ invalidatePriors()

void ScoutingSystem::invalidatePriors ( ) const
inline

Drops the cached squad priors (squads or attributes changed), so estimates match what a reloaded save computes.

◆ isForeign()

bool ScoutingSystem::isForeign ( const Player &  player) const
private

◆ isForeignTarget()

bool ScoutingSystem::isForeignTarget ( ScoutTargetKind  kind,
std::uint32_t  target_id 
) const
private

◆ isShortlisted()

bool ScoutingSystem::isShortlisted ( PlayerID  player_id) const

◆ knowledgeOf()

float ScoutingSystem::knowledgeOf ( PlayerID  player_id) const

Effective knowledge 0-100 of a player.

◆ makeRow()

ScoutedPlayerRow ScoutingSystem::makeRow ( const Player &  player) const
private

◆ markReportsSeen()

bool ScoutingSystem::markReportsSeen ( std::uint32_t  scout_id)

Marks a scout's reports as opened; false if none were unread.

◆ matchesFocus()

bool ScoutingSystem::matchesFocus ( const RecruitmentFocus &  focus,
const ScoutedPlayerRow &  row 
)
static

True if the estimated row satisfies focus.

◆ noiseFor()

ScoutingSystem::Noise ScoutingSystem::noiseFor ( const Player &  player,
float  knowledge 
) const
private

◆ observe()

void ScoutingSystem::observe ( PlayerID  player_id,
float  amount,
const ScoutProfile *  scout 
)

Adds observation (diminishing returns towards the cap).

◆ onDayAdvanced()

void ScoutingSystem::onDayAdvanced ( const GameDateValue &  date,
Inbox &  inbox 
)

Assignment progress, knowledge decay and shortlist alerts.

◆ onManagedMatch()

void ScoutingSystem::onManagedMatch ( TeamID  opponent_id)

The managed club faced opponent_id: its players become known.

◆ ownBestByRole()

std::array< float, ScoutingSystem::ROLE_COUNT > ScoutingSystem::ownBestByRole ( ) const
private

Best own overall per PlayerRole index (0 = none).

◆ priorMean()

float ScoutingSystem::priorMean ( TeamID  team_id,
std::size_t  group,
std::size_t  index 
) const
private

◆ progressAssignment()

void ScoutingSystem::progressAssignment ( ScoutAssignment &  assignment,
const GameDateValue &  date,
std::int32_t  ordinal,
Inbox &  inbox 
)
private

◆ pruneHistory()

void ScoutingSystem::pruneHistory ( )
private

◆ refreshScouts()

void ScoutingSystem::refreshScouts ( ) const
private

◆ removeFocus()

bool ScoutingSystem::removeFocus ( std::uint32_t  focus_id)

◆ removeFromShortlist()

bool ScoutingSystem::removeFromShortlist ( PlayerID  player_id)

◆ restore()

void ScoutingSystem::restore ( ScoutingState  restored)

◆ row()

std::optional< ScoutedPlayerRow > ScoutingSystem::row ( PlayerID  player_id) const

Estimated overall and potential range without attribute detail.

◆ scoutStatus()

ScoutStatus ScoutingSystem::scoutStatus ( std::uint32_t  scout_id) const

What a scout is doing (drives the scout page).

◆ scoutSummaries()

std::vector< ScoutSummary > ScoutingSystem::scoutSummaries ( ) const

Every scout with his status and report counters, in roster order.

◆ search()

std::vector< ScoutedPlayerRow > ScoutingSystem::search ( const ScoutSearchFilter &  filter) const

Search on estimated values, best estimated overall first.

◆ setBudgetProvider()

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.

◆ setManagedTeam()

void ScoutingSystem::setManagedTeam ( TeamID  team_id)

Binds the department to the managed club; a new club starts afresh.

◆ setScoutProvider()

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()).

◆ shortlistFlags()

std::uint8_t ScoutingSystem::shortlistFlags ( const Player &  player) const
private

◆ standardNormal()

float ScoutingSystem::standardNormal ( PlayerID  player_id,
std::uint64_t  key 
) const
private

◆ startAssignment()

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.

◆ targetCountries()

std::vector< TargetCountry > ScoutingSystem::targetCountries ( const ScoutExpertise &  expertise,
ScoutTargetKind  kind,
std::uint32_t  target_id,
LeagueID *  league 
) const
private

Countries of an assignment with their weights, plus its league.

◆ unreadReports() [1/2]

std::size_t ScoutingSystem::unreadReports ( ) const

Reports not yet opened, of every scout or of one.

◆ unreadReports() [2/2]

std::size_t ScoutingSystem::unreadReports ( std::uint32_t  scout_id) const

◆ upsertFocus()

std::uint32_t ScoutingSystem::upsertFocus ( RecruitmentFocus  focus)

Adds (id 0) or updates a focus; returns its id, 0 if full/invalid.

◆ view()

std::optional< ScoutedPlayerView > ScoutingSystem::view ( PlayerID  player_id) const

Estimated view of a player; nullopt if unknown.

◆ worldCountries()

std::vector< LeagueID > ScoutingSystem::worldCountries ( ) const
private

Member Data Documentation

◆ budget_provider

BudgetProvider ScoutingSystem::budget_provider
private

◆ cache_mutex

std::recursive_mutex ScoutingSystem::cache_mutex
mutableprivate

Cache lookups call one another while building summaries and estimates.

◆ gamedata

std::shared_ptr<GameData> ScoutingSystem::gamedata
private

◆ generated

std::unordered_map<std::uint32_t, ScoutExpertise> ScoutingSystem::generated
mutableprivate

Backgrounds of scouts not stored yet (identical once stored).

◆ POSITION_GROUPS

constexpr std::size_t ScoutingSystem::POSITION_GROUPS = 4
staticconstexprprivate

◆ priors

std::unordered_map<TeamID, TeamPrior> ScoutingSystem::priors
mutableprivate

Daily cache.

◆ ROLE_COUNT

constexpr std::size_t ScoutingSystem::ROLE_COUNT
staticconstexpr
Initial value:
=
static_cast<std::size_t>(std::to_underlying(PlayerRole::UNKNOWN))

◆ scout_provider

ScoutProvider ScoutingSystem::scout_provider
private

◆ scouts

std::vector<ScoutProfile> ScoutingSystem::scouts
mutableprivate

Cache of the provider.

◆ state

ScoutingState ScoutingSystem::state
private

The documentation for this class was generated from the following files: