From 864a5dd3197cc31f46546f095794e39e868b64c3 Mon Sep 17 00:00:00 2001 From: nicidob Date: Sat, 12 Feb 2022 02:38:03 -0500 Subject: [PATCH 1/2] composite based on nba data --- src/common/constants.basketball.ts | 24 ++++++++++----------- src/worker/core/GameSim.basketball/index.ts | 12 +++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/common/constants.basketball.ts b/src/common/constants.basketball.ts index 685cd9261c..cbfad16a10 100644 --- a/src/common/constants.basketball.ts +++ b/src/common/constants.basketball.ts @@ -3,11 +3,11 @@ import type { RatingKey } from "./types.basketball"; const COMPOSITE_WEIGHTS: CompositeWeights = { 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, @@ -23,7 +23,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights = { }, passing: { ratings: ["drb", "pss", "oiq"], - weights: [0.4, 1, 0.5], + weights: [0.25, 1, 0.2], skill: { label: "Ps", cutoff: 0.63, @@ -31,7 +31,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights = { }, turnovers: { ratings: [50, "ins", "pss", "oiq"], - weights: [0.5, 1, 1, -1], + weights: [2, 1, 0.75, -1], }, shootingAtRim: { ratings: ["hgt", "stre", "dnk", "oiq"], @@ -61,28 +61,28 @@ const COMPOSITE_WEIGHTS: CompositeWeights = { 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: [1.0, 0.4, 0.1], }, 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"], diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index 2a56d25366..613c5c4da3 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -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"); @@ -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, 2); const p = this.playersOnCourt[this.d][pickPlayer(ratios)]; this.recordStat(this.d, p, "stl"); this.recordPlay("stl", this.d, [ @@ -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); } @@ -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, 4); const p2 = this.playersOnCourt[this.d][pickPlayer(ratios)]; this.recordStat(this.d, p2, "blk"); @@ -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]); From ca5f00441755dd1f5df1000d6b09f2fd291d9293 Mon Sep 17 00:00:00 2001 From: nicidob Date: Sat, 12 Feb 2022 11:05:02 -0500 Subject: [PATCH 2/2] increase powers of steals and blocks --- src/common/constants.basketball.ts | 2 +- src/worker/core/GameSim.basketball/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/constants.basketball.ts b/src/common/constants.basketball.ts index cbfad16a10..634585fa85 100644 --- a/src/common/constants.basketball.ts +++ b/src/common/constants.basketball.ts @@ -74,7 +74,7 @@ const COMPOSITE_WEIGHTS: CompositeWeights = { }, blocking: { ratings: ["hgt", "jmp", "diq"], - weights: [1.0, 0.4, 0.1], + weights: [2.5, 1.3, 0.5], }, fouling: { ratings: [50, "hgt", "diq", "spd"], diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index 613c5c4da3..aad10b9d51 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -1407,7 +1407,7 @@ class GameSim { * @return {string} Currently always returns "stl". */ doStl(pStoleFrom: number) { - const ratios = this.ratingArray("stealing", this.d, 2); + 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, [ @@ -1669,7 +1669,7 @@ class GameSim { this.recordStat(this.o, p, "tpa"); } - const ratios = this.ratingArray("blocking", this.d, 4); + const ratios = this.ratingArray("blocking", this.d, 8); const p2 = this.playersOnCourt[this.d][pickPlayer(ratios)]; this.recordStat(this.d, p2, "blk");