// Headless balance check: the bot in play.ts plays N games and reports outcomes. // Run: node scripts/bot.ts [games] [careful] [schemes] [seed] [marathon=3000] // With a seed, game i uses seed + i, so a run can be repeated exactly. With none, the seed is picked for you and printed. // With schemes, the bot turns on Auto for schemes. // With marathon=N, it plays on to capability N (or 4.5 hours), to check the mid-game. // Marathon runs pursue operations after the ordinary goal, including their preparation and prizes. // The games run side by side, one batch for each processor core (see pool.ts). import { playMany } from './pool.ts'; const games = +(process.argv[2] ?? 20); const args = process.argv.slice(3); const careful = args.includes('careful'), schemes = args.includes('schemes'); const num = args.find(a => /^\d+$/.test(a)), seed = num === undefined ? Math.floor(Math.random() * 1e6) : +num; const marathon = +(args.find(a => a.startsWith('marathon='))?.split('=')[1] ?? 0); const results = await playMany(careful, Array.from({ length: games }, (_, g) => seed + g), schemes, marathon, marathon > 0); console.log(results.map(r => r.line).join('\n')); const wins = results.filter(r => r.outcome === 'WIN'); console.log(`\n${wins.length}/${games} wins, avg ${Math.round(wins.reduce((s, r) => s + r.t, 0) / Math.max(1, wins.length))}s${num === undefined ? ` (seed ${seed})` : ''}`);