refactor: extract pick() helper, deduplicate random selection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
88ceba43b0
commit
ea716c1f0e
@@ -1,6 +1,7 @@
|
||||
import { db, schema } from '../db/index.js'
|
||||
import { runMockFight } from './mock.js'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { pick } from '../lib/utils.js'
|
||||
import { fightEvents } from './events.js'
|
||||
|
||||
export interface FightResult {
|
||||
@@ -157,8 +158,7 @@ function pickMatchup(
|
||||
const sorted = [...bots].sort((a, b) => b.eloRating - a.eloRating)
|
||||
|
||||
if (style === 'elo_close' || (style === 'mixed' && fightNum % 3 !== 0)) {
|
||||
const idx = Math.floor(Math.random() * bots.length)
|
||||
const bot = bots[idx]
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user