Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nicidob committed Jan 13, 2022
1 parent 6241422 commit 8eb0d93
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
30 changes: 15 additions & 15 deletions src/worker/core/player/developSeason.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import type {

// (age coefficient, age offset) for mean, than std. dev.
const ratingsFormulas: Record<Exclude<RatingKey, "hgt">, Array<number>> = {
diq: [0.0023, -0.0524, -0.0, 0.0003],
dnk: [0.0018, -0.0465, -0.0003, 0.0091],
drb: [0.0026, -0.0648, 0.0, 0.0],
endu: [-0.012, 0.3214, 0.0016, -0.0357],
fg: [0.0011, -0.0236, -0.0004, 0.0191],
ft: [0.0018, -0.0396, -0.0007, 0.0285],
ins: [0.0005, -0.0197, 0.0003, 0.0108],
jmp: [-0.0051, 0.1082, 0.0041, -0.102],
oiq: [-0.0003, 0.0137, -0.0, 0.0014],
pss: [0.0019, -0.046, -0.0, 0.0001],
reb: [0.0019, -0.0506, -0.0, 0.0001],
spd: [-0.002, 0.0402, 0.001, -0.0252],
stre: [-0.0001, -0.0001, 0.0, 0.0],
tp: [0.0024, -0.0596, -0.0012, 0.0385],
diq: [0.0025, -0.056, -0.0, 0.0004],
dnk: [0.002, -0.0518, -0.0003, 0.0104],
drb: [0.0029, -0.0716, 0.0, 0.0],
endu: [-0.0135, 0.3619, 0.002, -0.0458],
fg: [0.0012, -0.0256, -0.0004, 0.0233],
ft: [0.0019, -0.0434, -0.0009, 0.039],
ins: [0.0007, -0.0246, 0.0004, 0.0132],
jmp: [-0.0055, 0.1173, 0.0053, -0.1313],
oiq: [-0.0003, 0.0163, -0.0001, 0.0016],
pss: [0.0021, -0.0512, -0.0, 0.0001],
reb: [0.0022, -0.0569, -0.0, 0.0002],
spd: [-0.0021, 0.0422, 0.0012, -0.0301],
stre: [-0.0001, 0.0, 0.0, 0.0],
tp: [0.0026, -0.0652, -0.0015, 0.0464],
};

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

const base_coef = [-0.0039, 0.1018, 0.0003, 0.0266];
const base_coef = [-0.0044, 0.1138, 0.0004, 0.0341];

val = base_coef[0] * age + base_coef[1];
const std_base = base_coef[2] * age + base_coef[3];
Expand Down
54 changes: 27 additions & 27 deletions src/worker/core/player/genRatings.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,102 +29,102 @@ const genRatings = (

const pca_comp = [
[
-0.04097378, 0.10708854, -0.37189642, -0.16707005, -0.31409436,
-0.29164582, 0.33714843, 0.10838294, -0.31849462, -0.12487201, -0.3799997,
0.12642711, -0.30714244, 0.03870837, -0.37182716,
-0.03143667, 0.13151142, -0.35923427, -0.14588372, -0.30707702,
-0.2923038, 0.35577568, 0.13378376, -0.30905554, -0.11226255, -0.36662078,
0.14404827, -0.3010302, 0.06513013, -0.38604742,
],
[
0.26861978, 0.3138044, 0.15214671, 0.24289334, 0.03620905, -0.02747153,
0.19318229, 0.47557852, 0.06119868, 0.21228091, 0.20542903, 0.40515214,
0.03863032, 0.4684178, -0.07482827,
0.28741613, 0.2948169, 0.18162839, 0.22216108, 0.04010548, -0.02320695,
0.16749835, 0.4756356, 0.08802667, 0.21357235, 0.24305432, 0.40340626,
0.05871636, 0.45862335, -0.05236033,
],
[
-0.18922555, 0.35164002, -0.30484948, 0.02890456, 0.30394453, 0.25071532,
0.28024483, -0.00872483, 0.26769468, 0.02539012, -0.5109063, -0.14047495,
0.2038116, 0.17138019, 0.29823953,
0.17881319, -0.36455768, 0.29882076, -0.03616037, -0.3152401, -0.26787323,
-0.27231044, -0.01128095, -0.2439317, -0.03754768, 0.50334144, 0.13699001,
-0.19139023, -0.1869137, -0.30742782,
],
];

const pca1 = 1.61 * hgt - 77.92 + random.realGauss(0, 15.4);
const pca2 = 0.51 * hgt - 24.93 + random.realGauss(0, 17.7);
const pca3 = 0.29 * hgt - 14.16 + random.realGauss(0, 9.3);
const pca1 = 1.62 * hgt - 78.12 + random.realGauss(0, 13.3);
const pca2 = 0.4 * hgt - 19.41 + random.realGauss(0, 14.9);
const pca3 = -0.28 * hgt + 13.35 + random.realGauss(0, 9.0);

const rawRatings = {
diq:
41.8 +
41.2 +
pca1 * pca_comp[0][0] +
pca2 * pca_comp[1][0] +
pca3 * pca_comp[2][0],
dnk:
47.6 +
46.6 +
pca1 * pca_comp[0][1] +
pca2 * pca_comp[1][1] +
pca3 * pca_comp[2][1],
drb:
49.5 +
49.1 +
pca1 * pca_comp[0][2] +
pca2 * pca_comp[1][2] +
pca3 * pca_comp[2][2],
endu:
34.3 +
32.1 +
pca1 * pca_comp[0][3] +
pca2 * pca_comp[1][3] +
pca3 * pca_comp[2][3],
fg:
43.1 +
42.3 +
pca1 * pca_comp[0][4] +
pca2 * pca_comp[1][4] +
pca3 * pca_comp[2][4],
ft:
43.1 +
42.4 +
pca1 * pca_comp[0][5] +
pca2 * pca_comp[1][5] +
pca3 * pca_comp[2][5],
hgt: hgt,
ins:
41.5 +
40.6 +
pca1 * pca_comp[0][7] +
pca2 * pca_comp[1][7] +
pca3 * pca_comp[2][7],
jmp:
51.6 +
50.1 +
pca1 * pca_comp[0][8] +
pca2 * pca_comp[1][8] +
pca3 * pca_comp[2][8],
oiq:
40.7 +
39.7 +
pca1 * pca_comp[0][9] +
pca2 * pca_comp[1][9] +
pca3 * pca_comp[2][9],
pss:
46.4 +
45.8 +
pca1 * pca_comp[0][10] +
pca2 * pca_comp[1][10] +
pca3 * pca_comp[2][10],
reb:
48.7 +
48.0 +
pca1 * pca_comp[0][11] +
pca2 * pca_comp[1][11] +
pca3 * pca_comp[2][11],
spd:
51.8 +
50.7 +
pca1 * pca_comp[0][12] +
pca2 * pca_comp[1][12] +
pca3 * pca_comp[2][12],
stre:
47.6 +
46.3 +
pca1 * pca_comp[0][13] +
pca2 * pca_comp[1][13] +
pca3 * pca_comp[2][13],
tp:
44.2 +
44.0 +
pca1 * pca_comp[0][14] +
pca2 * pca_comp[1][14] +
pca3 * pca_comp[2][14],
};

for (const key of helpers.keys(rawRatings)) {
rawRatings[key] = limitRating(rawRatings[key] * random.uniform(0.77, 1.23));
rawRatings[key] = limitRating(rawRatings[key] * random.uniform(0.8, 1.2));
}

const ratings = {
Expand Down
32 changes: 16 additions & 16 deletions src/worker/core/player/ovr.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import type { PlayerRatings } from "../../../common/types.basketball";
const ovr = (ratings: PlayerRatings): number => {
// See analysis/player-ovr-basketball
const r =
0.159 * (ratings.hgt - 47.5) +
0.0777 * (ratings.stre - 50.2) +
0.123 * (ratings.spd - 50.8) +
0.051 * (ratings.jmp - 48.7) +
0.0632 * (ratings.endu - 39.9) +
0.0126 * (ratings.ins - 42.4) +
0.0286 * (ratings.dnk - 49.5) +
0.0202 * (ratings.ft - 47.0) +
0.0726 * (ratings.tp - 47.1) +
0.133 * (ratings.oiq - 46.8) +
0.159 * (ratings.diq - 46.7) +
0.059 * (ratings.drb - 54.8) +
0.062 * (ratings.pss - 51.3) +
0.01 * (ratings.fg - 47.0) +
0.01 * (ratings.reb - 51.4) +
48.5;
0.0935 * ratings.diq +
0.042 * ratings.dnk +
0.0969 * ratings.drb +
0.00725 * ratings.endu +
-0.00948 * ratings.fg +
0.0488 * ratings.ft +
0.225 * ratings.hgt +
-0.0143 * ratings.ins +
0.0502 * ratings.jmp +
0.0974 * ratings.oiq +
0.0656 * ratings.pss +
0.0533 * ratings.reb +
0.156 * ratings.spd +
0.0962 * ratings.stre +
0.105 * ratings.tp +
-6.4;

// Fudge factor to keep ovr ratings the same as they used to be (back before 2018 ratings rescaling)
// +8 at 68
Expand Down

0 comments on commit 8eb0d93

Please sign in to comment.