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

composite based on nba data #408

Open
wants to merge 2 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
24 changes: 12 additions & 12 deletions src/common/constants.basketball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { RatingKey } from "./types.basketball";

const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
pace: {
ratings: ["spd", "jmp", "dnk", "tp", "drb", "pss"],
ratings: ["jmp", "dnk", "diq", "drb", "oiq"],
},
usage: {
ratings: ["ins", "dnk", "fg", "tp", "spd", "hgt", "drb", "oiq"],
weights: [1.5, 1, 1, 1, 0.5, 0.5, 0.5, 0.5],
ratings: ["ins", "fg", "dnk", "oiq", "drb", "jmp"],
weights: [1.0, 0.88, 0.5, 0.13, 0.1, 0.1],
skill: {
label: "V",
cutoff: 0.61,
Expand All @@ -23,15 +23,15 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
},
passing: {
ratings: ["drb", "pss", "oiq"],
weights: [0.4, 1, 0.5],
weights: [0.25, 1, 0.2],
skill: {
label: "Ps",
cutoff: 0.63,
},
},
turnovers: {
ratings: [50, "ins", "pss", "oiq"],
weights: [0.5, 1, 1, -1],
weights: [2, 1, 0.75, -1],
},
shootingAtRim: {
ratings: ["hgt", "stre", "dnk", "oiq"],
Expand Down Expand Up @@ -61,28 +61,28 @@ const COMPOSITE_WEIGHTS: CompositeWeights<RatingKey> = {
ratings: ["ft"],
},
rebounding: {
ratings: ["hgt", "stre", "jmp", "reb", "oiq", "diq"],
weights: [2, 0.1, 0.1, 2, 0.5, 0.5],
ratings: ["hgt", "reb", "diq"],
weights: [1, 1, 0.1],
skill: {
label: "R",
cutoff: 0.61,
},
},
stealing: {
ratings: [50, "spd", "diq"],
weights: [1, 1, 2],
ratings: ["spd", "diq"],
weights: [0.5, 1.0],
},
blocking: {
ratings: ["hgt", "jmp", "diq"],
weights: [2.5, 1.5, 0.5],
weights: [2.5, 1.3, 0.5],
},
fouling: {
ratings: [50, "hgt", "diq", "spd"],
weights: [3, 1, -1, -1],
},
drawingFouls: {
ratings: ["hgt", "spd", "drb", "dnk", "oiq"],
weights: [1, 1, 1, 1, 1],
ratings: ["hgt", "spd", "dnk", "pss", "reb"],
weights: [1, 0.6, 0.8, 0.4, 0.6],
},
defense: {
ratings: ["hgt", "stre", "spd", "jmp", "diq"],
Expand Down
12 changes: 6 additions & 6 deletions src/worker/core/GameSim.basketball/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ class GameSim {
* @return {string} Either "tov" or "stl" depending on whether the turnover was caused by a steal or not.
*/
doTov() {
const ratios = this.ratingArray("turnovers", this.o, 2);
const ratios = this.ratingArray("turnovers", this.o, 3);
const p = this.playersOnCourt[this.o][pickPlayer(ratios)];
this.recordStat(this.o, p, "tov");

Expand Down Expand Up @@ -1407,7 +1407,7 @@ class GameSim {
* @return {string} Currently always returns "stl".
*/
doStl(pStoleFrom: number) {
const ratios = this.ratingArray("stealing", this.d, 4);
const ratios = this.ratingArray("stealing", this.d, 3);
const p = this.playersOnCourt[this.d][pickPlayer(ratios)];
this.recordStat(this.d, p, "stl");
this.recordPlay("stl", this.d, [
Expand All @@ -1432,7 +1432,7 @@ class GameSim {
// Is this an "assisted" attempt (i.e. an assist will be recorded if it's made)
let passer: PlayerNumOnCourt | undefined;
if (this.probAst() > Math.random() && this.numPlayersOnCourt > 1) {
const ratios = this.ratingArray("passing", this.o, 10);
const ratios = this.ratingArray("passing", this.o, 5);
passer = pickPlayer(ratios, shooter);
}

Expand Down Expand Up @@ -1669,7 +1669,7 @@ class GameSim {
this.recordStat(this.o, p, "tpa");
}

const ratios = this.ratingArray("blocking", this.d, 10);
const ratios = this.ratingArray("blocking", this.d, 8);
const p2 = this.playersOnCourt[this.d][pickPlayer(ratios)];
this.recordStat(this.d, p2, "blk");

Expand Down Expand Up @@ -2107,14 +2107,14 @@ class GameSim {
(2 + this.team[this.o].compositeRating.rebounding)) >
Math.random()
) {
ratios = this.ratingArray("rebounding", this.d, 3);
ratios = this.ratingArray("rebounding", this.d, 2);
p = this.playersOnCourt[this.d][pickPlayer(ratios)];
this.recordStat(this.d, p, "drb");
this.recordPlay("drb", this.d, [this.team[this.d].player[p].name]);
return "drb";
}

ratios = this.ratingArray("rebounding", this.o, 5);
ratios = this.ratingArray("rebounding", this.o, 3);
p = this.playersOnCourt[this.o][pickPlayer(ratios)];
this.recordStat(this.o, p, "orb");
this.recordPlay("orb", this.o, [this.team[this.o].player[p].name]);
Expand Down