Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real Player Roster inspired development curves #320

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 93 additions & 142 deletions src/worker/core/player/developSeason.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,192 +10,144 @@ type RatingFormula = {
changeLimits: (age: number) => [number, number];
};

const shootingFormula: RatingFormula = {
const defaultFormula: RatingFormula = {
ageModifier: (age: number) => {
// Reverse most of the age-related decline in calcBaseChange
if (age <= 27) {
return 0;
}

if (age <= 29) {
return 0.5;
}

if (age <= 31) {
return 1.5;
}

return 2;
return 0;
},
changeLimits: () => [-3, 13],
};
const iqFormula: RatingFormula = {
ageModifier: (age: number) => {
if (age <= 21) {
return 4;
}

changeLimits: (age: number) => {
if (age <= 23) {
return 3;
}

// Reverse most of the age-related decline in calcBaseChange
if (age <= 27) {
return 0;
}

if (age <= 29) {
return 0.5;
}

if (age <= 31) {
return 1.5;
return [-2, 20];
} else if (age <= 25) {
return [-5, 10];
}

return 2;
},
changeLimits: age => {
if (age > 24) {
return [-3, 9];
}

// For 19: [-3, 32]
// For 23: [-3, 12]
return [-3, 7 + 5 * (24 - age)];
const age_adj = -0.5 * (age - 25);
return [-5 + age_adj, 5 + age_adj];
},
};

const ratingsFormulas: Record<Exclude<RatingKey, "hgt">, RatingFormula> = {
stre: {
ageModifier: () => 0,
changeLimits: () => [-Infinity, Infinity],
ageModifier: (age: number) => {
return -0.4;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
spd: {
ageModifier: (age: number) => {
if (age <= 27) {
return 0;
}

if (age <= 30) {
return -2;
if (age <= 20) {
return -0.1;
}

if (age <= 35) {
return -3;
}

if (age <= 40) {
return -4;
}

return -8;
return -0.2 * (age - 20) + -0.1;
},
changeLimits: () => [-12, 2],
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
jmp: {
jmp: defaultFormula,
endu: {
ageModifier: (age: number) => {
if (age <= 26) {
return 0;
}

if (age <= 30) {
return -3;
}

if (age <= 35) {
return -4;
}

if (age <= 40) {
return -5;
if (age <= 20) {
return 3.7;
}

return -10;
return -0.5 * (age - 20) + 3.7;
},
changeLimits: () => [-12, 2],
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
endu: {
dnk: {
ageModifier: (age: number) => {
if (age <= 23) {
return random.uniform(0, 9);
if (age <= 20) {
return -0.2;
}

if (age <= 30) {
return 0;
return 0.1 * (age - 20) + -0.2;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
ins: {
ageModifier: (age: number) => {
if (age <= 20) {
return -1.1;
}

if (age <= 35) {
return -2;
return 0.2 * (age - 20) + -1.1;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
ft: {
ageModifier: (age: number) => {
if (age <= 20) {
return -0.4;
}

if (age <= 40) {
return -4;
return 0.1 * (age - 20) + -0.4;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
fg: defaultFormula,
tp: {
ageModifier: (age: number) => {
if (age <= 20) {
return -1.2;
}

return -8;
return 0.2 * (age - 20) + -1.2;
},
changeLimits: () => [-11, 19],
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
dnk: {
oiq: {
ageModifier: (age: number) => {
// Like shootingForumla, except for old players
if (age <= 27) {
return 0;
return 0;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
diq: {
ageModifier: (age: number) => {
if (age <= 20) {
return -0.7;
}

return 0.5;
return 0.1 * (age - 20) + -0.7;
},
changeLimits: () => [-3, 13],
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
ins: shootingFormula,
ft: shootingFormula,
fg: shootingFormula,
tp: shootingFormula,
oiq: iqFormula,
diq: iqFormula,
drb: {
ageModifier: shootingFormula.ageModifier,
changeLimits: () => [-2, 5],
ageModifier: (age: number) => {
if (age <= 20) {
return -1.4;
}
return 0.2 * (age - 20) + -1.4;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
pss: {
ageModifier: shootingFormula.ageModifier,
changeLimits: () => [-2, 5],
ageModifier: (age: number) => {
if (age <= 20) {
return -1.1;
}
return 0.2 * (age - 20) + -1.1;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
reb: {
ageModifier: shootingFormula.ageModifier,
changeLimits: () => [-2, 5],
ageModifier: (age: number) => {
if (age <= 20) {
return -0.7;
}
return 0.1 * (age - 20) + -0.7;
},
changeLimits: (age: number) => defaultFormula.changeLimits(age),
},
};

const calcBaseChange = (age: number, coachingRank: number): number => {
let val: number;

if (age <= 21) {
val = 2;
} else if (age <= 25) {
val = 1;
} else if (age <= 27) {
val = 0;
} else if (age <= 29) {
val = -1;
} else if (age <= 31) {
val = -2;
} else if (age <= 34) {
val = -3;
} else if (age <= 40) {
val = -4;
} else if (age <= 43) {
val = -5;
if (age <= 19) {
val = 2.2;
} else {
val = -6;
val = -0.3 * (age - 19) + 2.2;
}

// Noise
if (age <= 23) {
val += helpers.bound(random.realGauss(0, 5), -4, 20);
} else if (age <= 25) {
val += helpers.bound(random.realGauss(0, 5), -4, 10);
val += helpers.bound(random.realGauss(0, 8), -2, 8);
} else if (age <= 28) {
val += helpers.bound(random.realGauss(0, 6), -2, 6);
} else {
val += helpers.bound(random.realGauss(0, 3), -2, 4);
val += helpers.bound(random.realGauss(0, 4), -2, 4);
}

// Modulate by coaching. g.get("numActiveTeams") doesn't exist when upgrading DB, but that doesn't matter
Expand Down Expand Up @@ -227,7 +179,6 @@ const developSeason = (
ratings.hgt += 1;
}
}

const baseChange = calcBaseChange(age, coachingRank);

for (const key of helpers.keys(ratingsFormulas)) {
Expand All @@ -237,7 +188,7 @@ const developSeason = (
ratings[key] = limitRating(
ratings[key] +
helpers.bound(
(baseChange + ageModifier) * random.uniform(0.4, 1.4),
(baseChange + ageModifier) * random.uniform(0.1, 1.7),
changeLimits[0],
changeLimits[1],
),
Expand Down
Loading