Player12
An open source football management simulator
Loading...
Searching...
No Matches
Standings Namespace Reference

Run-in maths of a league table: which outcomes are mathematically decided (title, promotion, play-off and continental places, survival) and what a club still needs from its own games. More...

Classes

struct  ClinchReport
 
struct  RaceFixture
 
struct  RaceInput
 
struct  RaceNeed
 
struct  RacePlaces
 Table places that decide something. Promotion, play-off and continental places count from the top (play-off places follow the promotion places; continental includes continental_top), relegation from the bottom. 0 means the league has none. More...
 

Enumerations

enum class  Race : uint8_t {
  TITLE , PROMOTION , PLAY_OFF , CONTINENTAL_TOP ,
  CONTINENTAL , SURVIVAL
}
 
enum class  RaceState : uint8_t { NONE , OPEN , SECURED , LOST }
 
enum class  Clinch : uint8_t {
  OPEN , CHAMPION , PROMOTED , PLAY_OFF ,
  CONTINENTAL_TOP , CONTINENTAL , SAFE , RELEGATED
}
 

Functions

std::vector< StandingRow > compute (const League &league, const Calendar &calendar, const GameData &gamedata)
 Computes a league table from the played league fixtures.
 
uint16_t raceCutoff (Race race, const RacePlaces &places, size_t clubs)
 
ClinchReport clinchReport (const RaceInput &input, const RacePlaces &places, TeamID team)
 
Clinch clinchStatus (const RaceInput &input, const RacePlaces &places, TeamID team)
 
std::vector< ClinchReport > clinchReports (const RaceInput &input, const RacePlaces &places)
 
std::vector< RaceNeed > whatYouNeed (const RaceInput &input, const RacePlaces &places, TeamID team)
 What team needs in its still open races, most ambitious first.
 
RaceInput raceInput (const League &league, const Calendar &calendar, const GameData &gamedata)
 
RacePlaces racePlaces (const GameData &gamedata, const ContinentalCompetitions *continental, LeagueID league_id)
 Deciding places of a league: promotion and relegation as the season-end movements apply them; continental places (top divisions only) from the current association ranking, minus the place the domestic cup winner can take.
 

Variables

constexpr uint16_t POINTS_FOR_WIN = 3
 
constexpr uint16_t POINTS_FOR_DRAW = 1
 
constexpr size_t FORM_LENGTH = 5
 
constexpr size_t RACE_COUNT = 6
 
constexpr uint16_t MAX_NEED_GAMES = 6
 

Detailed Description

Run-in maths of a league table: which outcomes are mathematically decided (title, promotion, play-off and continental places, survival) and what a club still needs from its own games.

Everything is derived from the fixtures themselves: the played results give the current table and the head-to-head records, the unplayed ones the games still to come. A result is only reported as decided when it holds for every combination of the remaining results and every possible score, under the league's tie-break rule (see Standings::compute).

Enumeration Type Documentation

◆ Clinch

enum class Standings::Clinch : uint8_t
strong

Headline status of a club, the best decided outcome first.

Enumerator
OPEN 
CHAMPION 
PROMOTED 
PLAY_OFF 
CONTINENTAL_TOP 
CONTINENTAL 
SAFE 
RELEGATED 

◆ Race

enum class Standings::Race : uint8_t
strong

The races a club can be part of, most ambitious first.

Enumerator
TITLE 
PROMOTION 
PLAY_OFF 
CONTINENTAL_TOP 
CONTINENTAL 
SURVIVAL 

◆ RaceState

enum class Standings::RaceState : uint8_t
strong
Enumerator
NONE 

The league has no such places.

OPEN 

Still undecided (or too early to prove either way).

SECURED 

Guaranteed whatever happens.

LOST 

Out of reach whatever happens.

Function Documentation

◆ clinchReport()

Standings::ClinchReport Standings::clinchReport ( const RaceInput &  input,
const RacePlaces &  places,
TeamID  team 
)

Decided races and headline status of one club.

◆ clinchReports()

std::vector< Standings::ClinchReport > Standings::clinchReports ( const RaceInput &  input,
const RacePlaces &  places 
)

clinchReport for every club, in input.teams order.

◆ clinchStatus()

Standings::Clinch Standings::clinchStatus ( const RaceInput &  input,
const RacePlaces &  places,
TeamID  team 
)

Headline status of one club (see clinchReport).

◆ compute()

std::vector< StandingRow > Standings::compute ( const League &  league,
const Calendar &  calendar,
const GameData &  gamedata 
)

Computes a league table from the played league fixtures.

The calendar is the single source of truth. With the league's TieBreakRule::GOAL_DIFFERENCE teams are ordered by points, goal difference, goals scored, then a head-to-head mini-league (points, goal difference) among the tied teams; with TieBreakRule::HEAD_TO_HEAD the mini-league comes right after points, followed by overall goal difference and goals scored. Remaining ties fall back to team name, then team ID.

◆ raceCutoff()

uint16_t Standings::raceCutoff ( Race  race,
const RacePlaces &  places,
size_t  clubs 
)

Number of places (from the top) that decide a race; 0 = no such race.

◆ raceInput()

Standings::RaceInput Standings::raceInput ( const League &  league,
const Calendar &  calendar,
const GameData &  gamedata 
)

Fixtures, clubs and tie-break rule of a league from the calendar.

◆ racePlaces()

Standings::RacePlaces Standings::racePlaces ( const GameData &  gamedata,
const ContinentalCompetitions *  continental,
LeagueID  league_id 
)

Deciding places of a league: promotion and relegation as the season-end movements apply them; continental places (top divisions only) from the current association ranking, minus the place the domestic cup winner can take.

◆ whatYouNeed()

std::vector< Standings::RaceNeed > Standings::whatYouNeed ( const RaceInput &  input,
const RacePlaces &  places,
TeamID  team 
)

What team needs in its still open races, most ambitious first.

Worked out only in the run-in (at most MAX_NEED_GAMES league games left for the club); earlier, or when the search would be too long, the list is empty. Races already decided are left out.

Variable Documentation

◆ FORM_LENGTH

constexpr size_t Standings::FORM_LENGTH = 5
constexpr

◆ MAX_NEED_GAMES

constexpr uint16_t Standings::MAX_NEED_GAMES = 6
inlineconstexpr

◆ POINTS_FOR_DRAW

constexpr uint16_t Standings::POINTS_FOR_DRAW = 1
constexpr

◆ POINTS_FOR_WIN

constexpr uint16_t Standings::POINTS_FOR_WIN = 3
constexpr

◆ RACE_COUNT

constexpr size_t Standings::RACE_COUNT = 6
inlineconstexpr