From 8666f98bb1bff4c7539956a8dc8c7a9bfa1cbc8e Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 21 Mar 2025 20:22:45 -0500 Subject: [PATCH 1/6] init commit --- src/worker/core/GameSim.basketball/index.ts | 32 ++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index 7eea245d80..5b9391fed8 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -2110,9 +2110,39 @@ class GameSim extends GameSimBase { probMake *= Math.sqrt(this.possessionLength / 8); } + /* + TODO: do some additional research to determine what the % bounds should be. + Preliminary analysis says that a 'great' passer should increase shot probability ~ 4% + + However, what if a pass comes from a 'bad' passer? Or what if the pass is from a 'great' passer, but external factors + (such as the pass being contested) make the pass less effective? We will set the lower bound to -2.5% for now, and 4% for the upper bound. + We want the random number to be skewed to the higher number, as there are ~ 1.5-2 AST/TOV ratio for NBA teams + https://www.basketball-reference.com/leagues/NBA_2025.html#per_game-team + */ + const passQuality = (passer: number): number => { + const upperBound = 0.04; + const lowerBound = -0.025; + const p = this.playersOnCourt[this.o][passer]; + const passAtr = this.team[this.o].player[p].compositeRating.passing; + + // Scale passAtr (0-1) to influence the skewing factor + const skewFactor = + (passAtr / 100) * (upperBound - lowerBound) + lowerBound; + + // Generate a random value within bounds, skewed by passAtr + const passRating = + Math.random() * (upperBound - lowerBound) + lowerBound; + if (passRating + skewFactor < lowerBound) { + return lowerBound; + } else if (passRating + skewFactor > upperBound) { + return upperBound; + } + return passRating + skewFactor; + }; + // Assisted shots are easier if (passer !== undefined) { - probMake += 0.025; + probMake += passQuality(passer); } } From a8b799cb7e87d847500e564a2846e6644137f789 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 21 Mar 2025 20:23:03 -0500 Subject: [PATCH 2/6] remove this --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index c5967f341a..be96758b13 100644 --- a/TODO +++ b/TODO @@ -905,7 +905,6 @@ still too much overtime scoring https://discord.com/channels/290013534023057409/ show previous salary on re-signing table https://old.reddit.com/r/BasketballGM/comments/z99cby/monthly_suggestions_thread/izjihq3/ -dedicated page listing all owned draft picks, including links to trades where they were acquired https://old.reddit.com/r/BasketballGM/comments/z99cby/monthly_suggestions_thread/j1a3nws/ show totals for pts/reb/ast/etc in play by play like "J. Brown Driving layup (12 pts) D. White (3 AST)" https://old.reddit.com/r/BasketballGM/comments/z99cby/monthly_suggestions_thread/j26zhxu/ From f81d503a8cf4aff53c3ea1a8db4f73108725cd1d Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 22 Mar 2025 14:54:58 -0500 Subject: [PATCH 3/6] simplify passQuality and change numbers --- src/worker/core/GameSim.basketball/index.ts | 28 ++++++--------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index 5b9391fed8..b299f830c0 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -2111,33 +2111,19 @@ class GameSim extends GameSimBase { } /* - TODO: do some additional research to determine what the % bounds should be. - Preliminary analysis says that a 'great' passer should increase shot probability ~ 4% - - However, what if a pass comes from a 'bad' passer? Or what if the pass is from a 'great' passer, but external factors - (such as the pass being contested) make the pass less effective? We will set the lower bound to -2.5% for now, and 4% for the upper bound. - We want the random number to be skewed to the higher number, as there are ~ 1.5-2 AST/TOV ratio for NBA teams + We want the % chance for better shot to be a higher number, as there are ~ 1.5-2 AST/TOV ratio for NBA teams https://www.basketball-reference.com/leagues/NBA_2025.html#per_game-team */ const passQuality = (passer: number): number => { - const upperBound = 0.04; - const lowerBound = -0.025; + const upperBound = 0.03; + const lowerBound = -0.015; const p = this.playersOnCourt[this.o][passer]; - const passAtr = this.team[this.o].player[p].compositeRating.passing; - - // Scale passAtr (0-1) to influence the skewing factor - const skewFactor = - (passAtr / 100) * (upperBound - lowerBound) + lowerBound; - - // Generate a random value within bounds, skewed by passAtr + // 100 / 5000 -> 0.02, 50 -> 0.01, 0 -> 0 + const passAtr = + this.team[this.o].player[p].compositeRating.passing / 5000; const passRating = Math.random() * (upperBound - lowerBound) + lowerBound; - if (passRating + skewFactor < lowerBound) { - return lowerBound; - } else if (passRating + skewFactor > upperBound) { - return upperBound; - } - return passRating + skewFactor; + return passRating + passAtr; }; // Assisted shots are easier From 1c4eea3f6d37d4a5445b8d008c2d49742870f849 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 28 Mar 2025 15:14:22 -0500 Subject: [PATCH 4/6] scale passRating to be linear to the passAtr --- src/worker/core/GameSim.basketball/index.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index b299f830c0..a0693011c0 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -2118,12 +2118,10 @@ class GameSim extends GameSimBase { const upperBound = 0.03; const lowerBound = -0.015; const p = this.playersOnCourt[this.o][passer]; - // 100 / 5000 -> 0.02, 50 -> 0.01, 0 -> 0 const passAtr = - this.team[this.o].player[p].compositeRating.passing / 5000; - const passRating = - Math.random() * (upperBound - lowerBound) + lowerBound; - return passRating + passAtr; + this.team[this.o].player[p].compositeRating.passing / 100; + const passRating = lowerBound + passAtr * (upperBound - lowerBound); + return passRating; }; // Assisted shots are easier From af2767c82496f00056d06f6db812bf5344e1e838 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 29 Mar 2025 23:04:52 -0500 Subject: [PATCH 5/6] Increase the percentage, but can roll this back if numbers are too much --- src/worker/core/GameSim.basketball/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index a0693011c0..8fdffd486c 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -2111,6 +2111,11 @@ class GameSim extends GameSimBase { } /* + To calculate the upper bound, we take Ast / Potential Ast to get conversion rate for shots + Then we compare this to the teams FG% for the best shooters. The avg seems to be around 4% higher. + The number is scaled down a bit, as to not affect shot probability too much + https://www.nba.com/stats/players/passing?dir=D&sort=POTENTIAL_AST + We want the % chance for better shot to be a higher number, as there are ~ 1.5-2 AST/TOV ratio for NBA teams https://www.basketball-reference.com/leagues/NBA_2025.html#per_game-team */ @@ -2118,8 +2123,7 @@ class GameSim extends GameSimBase { const upperBound = 0.03; const lowerBound = -0.015; const p = this.playersOnCourt[this.o][passer]; - const passAtr = - this.team[this.o].player[p].compositeRating.passing / 100; + const passAtr = this.team[this.o].player[p].compositeRating.passing; const passRating = lowerBound + passAtr * (upperBound - lowerBound); return passRating; }; From 724c58e292428338475b34451892127131cd4d60 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 29 Mar 2025 23:05:07 -0500 Subject: [PATCH 6/6] increase upepr bound and add comment --- src/worker/core/GameSim.basketball/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/worker/core/GameSim.basketball/index.ts b/src/worker/core/GameSim.basketball/index.ts index 8fdffd486c..293393bf0a 100644 --- a/src/worker/core/GameSim.basketball/index.ts +++ b/src/worker/core/GameSim.basketball/index.ts @@ -2112,15 +2112,14 @@ class GameSim extends GameSimBase { /* To calculate the upper bound, we take Ast / Potential Ast to get conversion rate for shots - Then we compare this to the teams FG% for the best shooters. The avg seems to be around 4% higher. - The number is scaled down a bit, as to not affect shot probability too much + Then we compare this to the teams FG% for the best shooters. The avg seems to be around ~7-8% higher. https://www.nba.com/stats/players/passing?dir=D&sort=POTENTIAL_AST We want the % chance for better shot to be a higher number, as there are ~ 1.5-2 AST/TOV ratio for NBA teams https://www.basketball-reference.com/leagues/NBA_2025.html#per_game-team */ const passQuality = (passer: number): number => { - const upperBound = 0.03; + const upperBound = 0.08; const lowerBound = -0.015; const p = this.playersOnCourt[this.o][passer]; const passAtr = this.team[this.o].player[p].compositeRating.passing;