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

How an AI club negotiates to borrow one of the managed club's players. More...

Classes

struct  BorrowerContext
 
struct  BorrowerReply
 

Enumerations

enum class  Why : std::uint8_t {
  WithinBudget , Improved , WageRoom , FeeInsteadOfWages ,
  ObligationDropped , AppearancesCut , FinalOffer , Unrealistic ,
  Insulted , OutOfPatience , NoWageRoom , DeadlineDay ,
  COUNT
}
 

Functions

const char * whyKey (Why why)
 
bool isValid (const LoanTerms &terms)
 
int loanWeeks (const BorrowerContext &context, LoanDuration duration)
 
double expectedAppearances (const BorrowerContext &context, LoanDuration duration)
 
double unplayedOdds (double expected, std::uint8_t minimum)
 
std::uint8_t maxWageShare (const BorrowerContext &context)
 
double borrowerCost (const BorrowerContext &context, const LoanTerms &terms)
 
double effectiveCeiling (const BorrowerContext &context)
 
bool affordable (const BorrowerContext &context, const LoanTerms &terms)
 
BorrowerReply respond (const BorrowerContext &context, const LoanTerms &current, const LoanTerms &asked, double roll)
 
LoanTerms openingOffer (const BorrowerContext &context, LoanDuration duration, std::uint8_t share, int age, double option_roll)
 
std::uint32_t ceilingFor (const BorrowerContext &context, const LoanTerms &opening, double roll)
 

Detailed Description

How an AI club negotiates to borrow one of the managed club's players.

The borrower has a hidden ceiling on what the loan may cost it, measured by borrowerCost(): the share of the wage it pays over the loan, the loan fee, a recall clause and the expected fee for appearances it fails to give him. Its wage room caps the share it can take on, its budget the fees, and a mandatory purchase must stay near the player's value. It answers the club's counters on later days with structures of its own (a fee instead of a bigger share, an option instead of an obligation, fewer guaranteed appearances), runs out of patience, walks away from demands far beyond its ceiling and concedes faster near the deadline, like the buyer (BuyerNegotiation, whose moves and decisions it shares). Pure rules: every draw is passed in.

Enumeration Type Documentation

◆ Why

enum class LoanNegotiation::Why : std::uint8_t
strong

Why the borrower answered the way it did.

Enumerator
WithinBudget 
Improved 
WageRoom 

Its wage room caps the share it can pay.

FeeInsteadOfWages 

A loan fee in place of a bigger share.

ObligationDropped 

An option to buy instead of an obligation.

AppearancesCut 

Fewer guaranteed appearances.

FinalOffer 
Unrealistic 
Insulted 
OutOfPatience 
NoWageRoom 

It can no longer fit his wage at all.

DeadlineDay 
COUNT 

Function Documentation

◆ affordable()

bool LoanNegotiation::affordable ( const BorrowerContext &  context,
const LoanTerms &  terms 
)

The terms fit its wage room and budget (cost aside).

◆ borrowerCost()

double LoanNegotiation::borrowerCost ( const BorrowerContext &  context,
const LoanTerms &  terms 
)

What terms cost the borrower over the loan.

◆ ceilingFor()

std::uint32_t LoanNegotiation::ceilingFor ( const BorrowerContext &  context,
const LoanTerms &  opening,
double  roll 
)

Ceiling of a borrower opening with opening, drawn with roll.

◆ effectiveCeiling()

double LoanNegotiation::effectiveCeiling ( const BorrowerContext &  context)

The ceiling lifted by deadline pressure.

◆ expectedAppearances()

double LoanNegotiation::expectedAppearances ( const BorrowerContext &  context,
LoanDuration  duration 
)

Appearances the borrower expects to give him over the loan.

◆ isValid()

bool LoanNegotiation::isValid ( const LoanTerms &  terms)

True when the loan terms are consistent (shares, clauses).

◆ loanWeeks()

int LoanNegotiation::loanWeeks ( const BorrowerContext &  context,
LoanDuration  duration 
)

Weeks a loan of duration runs from now.

◆ maxWageShare()

std::uint8_t LoanNegotiation::maxWageShare ( const BorrowerContext &  context)

Highest wage share (whole percent) its wage room allows.

◆ openingOffer()

LoanTerms LoanNegotiation::openingOffer ( const BorrowerContext &  context,
LoanDuration  duration,
std::uint8_t  share,
int  age,
double  option_roll 
)

Opening offer for a loan of duration: share of the wage (capped by the wage room) and, drawn with option_roll for a young player, an option to buy.

◆ respond()

BorrowerReply LoanNegotiation::respond ( const BorrowerContext &  context,
const LoanTerms &  current,
const LoanTerms &  asked,
double  roll 
)

Answer to the club's asked terms while current is on the table. roll in [0, 1) picks how the borrower reshapes its proposal.

◆ unplayedOdds()

double LoanNegotiation::unplayedOdds ( double  expected,
std::uint8_t  minimum 
)

Odds he plays fewer than minimum games when expected are likely.

◆ whyKey()

const char * LoanNegotiation::whyKey ( Why  why)

Language key describing why (e.g. "LOAN_WHY_WAGE_ROOM").