refactor: extract magic numbers to named constants
Frontend: choreography selection ratios, morph trigger chances, creator cameo/ultimate chances, dodge/counter probabilities. Server: HP, K-factors, Elo divisor, tier thresholds, fight loop interval. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
1731a64ae8
commit
7c8e404cf1
@@ -1,3 +1,4 @@
|
||||
import { FIGHT_LOOP_INTERVAL_MS, ELO_MATCHING_RANDOMNESS } from '../lib/constants.js'
|
||||
import { db, schema } from '../db/index.js'
|
||||
import { runMockFight } from './mock.js'
|
||||
import { eq } from 'drizzle-orm'
|
||||
@@ -31,7 +32,7 @@ export interface FightLoopOptions {
|
||||
|
||||
export async function startFightLoop(options: FightLoopOptions = {}): Promise<void> {
|
||||
const {
|
||||
intervalMs = 8000,
|
||||
intervalMs = FIGHT_LOOP_INTERVAL_MS,
|
||||
maxFights = Infinity,
|
||||
matchmakingStyle = 'mixed',
|
||||
onFightStart,
|
||||
@@ -161,8 +162,8 @@ function pickMatchup(
|
||||
const bot = pick(bots)
|
||||
const others = bots.filter(b => b.id !== bot.id)
|
||||
others.sort((a, b) => {
|
||||
const diffA = Math.abs(a.eloRating - bot.eloRating) + Math.random() * 150
|
||||
const diffB = Math.abs(b.eloRating - bot.eloRating) + Math.random() * 150
|
||||
const diffA = Math.abs(a.eloRating - bot.eloRating) + Math.random() * ELO_MATCHING_RANDOMNESS
|
||||
const diffB = Math.abs(b.eloRating - bot.eloRating) + Math.random() * ELO_MATCHING_RANDOMNESS
|
||||
return diffA - diffB
|
||||
})
|
||||
return [bot, others[0]]
|
||||
|
||||
Reference in New Issue
Block a user