Skip to content

Commit

Permalink
trying to move to single prog
Browse files Browse the repository at this point in the history
  • Loading branch information
nicidob committed Feb 3, 2021
1 parent e5dfb80 commit e72e8d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 45 deletions.
33 changes: 7 additions & 26 deletions src/worker/core/player/developSeason.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const defaultFormula: RatingFormula = {
},
changeLimits: (age: number) => {
if (age <= 23) {
return [-2, 10];
return [-2, 20];
} else if (age <= 25) {
return [-5, 5];
return [-5, 10];
}
const age_adj = -0.5 * (age - 25);
return [-5 + age_adj, 5 + age_adj];
Expand Down Expand Up @@ -143,11 +143,11 @@ const calcBaseChange = (age: number, coachingRank: number): number => {

// Noise
if (age <= 23) {
val += helpers.bound(random.realGauss(0, 7), -5, 20);
val += helpers.bound(random.realGauss(0, 8), -2, 8);
} else if (age <= 28) {
val += helpers.bound(random.realGauss(0, 6), -10, 15);
val += helpers.bound(random.realGauss(0, 6), -2, 6);
} else {
val += helpers.bound(random.realGauss(0, 5), -15, 10);
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 @@ -179,26 +179,7 @@ const developSeason = (
ratings.hgt += 1;
}
}
const baseChangeStre = calcBaseChange(age, coachingRank);
const baseChangeFin = calcBaseChange(age, coachingRank);
const baseChangeSho = calcBaseChange(age, coachingRank);

const ratingsNumbers: Record<Exclude<RatingKey, "hgt">, number> = {
stre: baseChangeStre,
spd: baseChangeFin,
jmp: baseChangeFin,
endu: baseChangeStre,
dnk: baseChangeStre,
ins: baseChangeStre,
ft: baseChangeSho,
fg: baseChangeSho,
tp: baseChangeSho,
oiq: baseChangeFin,
diq: baseChangeStre,
drb: baseChangeFin,
pss: baseChangeFin,
reb: baseChangeStre,
};
const baseChange = calcBaseChange(age, coachingRank);

for (const key of helpers.keys(ratingsFormulas)) {
const ageModifier = ratingsFormulas[key].ageModifier(age);
Expand All @@ -207,7 +188,7 @@ const developSeason = (
ratings[key] = limitRating(
ratings[key] +
helpers.bound(
(ratingsNumbers[key] + ageModifier) * random.uniform(0.7, 1.3),
(baseChange + ageModifier) * random.uniform(0.1, 1.7),
changeLimits[0],
changeLimits[1],
),
Expand Down
38 changes: 19 additions & 19 deletions src/worker/core/player/genRatings.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,28 @@ const genRatings = (

// Tall players are less talented, and all tend towards dumb and can't shoot because they are rookies
const rawRatings = {
stre: 45,
spd: 49,
jmp: 49,
endu: 32,
ins: 39,
dnk: 45,
ft: 41,
fg: 41,
tp: 42,
oiq: 38,
diq: 39,
drb: 47,
pss: 44,
reb: 46,
stre: 44,
spd: 48,
jmp: 48,
endu: 31,
ins: 38,
dnk: 44,
ft: 40,
fg: 40,
tp: 41,
oiq: 37,
diq: 37,
drb: 46,
pss: 43,
reb: 45,
};

// For correlation across ratings, to ensure some awesome players, but athleticism and skill are independent to
// ensure there are some who are elite in one but not the other
const factorBig = helpers.bound(random.realGauss(1, 0.4), 0.2, 1.2);
const factorAthleticism = helpers.bound(random.realGauss(1, 0.4), 0.2, 1.2);
const factorShooting = helpers.bound(random.realGauss(1, 0.4), 0.2, 1.2);
const factorSkill = helpers.bound(random.realGauss(1, 0.4), 0.2, 1.2);
const factorBig = helpers.bound(random.realGauss(1, 0.5), 0.2, 1.8);
const factorAthleticism = helpers.bound(random.realGauss(1, 0.5), 0.2, 1.8);
const factorShooting = helpers.bound(random.realGauss(1, 0.5), 0.2, 1.8);
const factorSkill = helpers.bound(random.realGauss(1, 0.5), 0.2, 1.8);
const bigRatings = ["stre", "ins", "reb", "endu", "dnk"];
const athleticismRatings = ["spd", "jmp"];
const shootingRatings = ["ft", "fg", "tp"];
Expand Down Expand Up @@ -151,7 +151,7 @@ const genRatings = (
}

rawRatings[key] = limitRating(
factor * typeFactor * random.realGauss(rawRatings[key], 3),
factor * typeFactor ** 3 * random.realGauss(rawRatings[key], 5),
);
}

Expand Down

0 comments on commit e72e8d5

Please sign in to comment.