Revert "Special bot names (#2552)"

This reverts commit 8f32746bb2.
This commit is contained in:
evanpelle
2026-01-01 16:32:57 -08:00
parent e4a6e3bd20
commit 793efe4dd1
2 changed files with 7 additions and 229 deletions
+7 -48
View File
@@ -4,16 +4,11 @@ import { PseudoRandom } from "../PseudoRandom";
import { GameID } from "../Schemas";
import { simpleHash } from "../Util";
import { SpawnExecution } from "./SpawnExecution";
import {
COMMUNITY_FULL_ELF_NAMES,
COMMUNITY_PREFIXES,
SPECIAL_FULL_ELF_NAMES,
} from "./utils/BotNames";
import { BOT_NAME_PREFIXES, BOT_NAME_SUFFIXES } from "./utils/BotNames";
export class BotSpawner {
private random: PseudoRandom;
private bots: SpawnExecution[] = [];
private nameIndex = 0;
constructor(
private gs: Game,
@@ -29,13 +24,9 @@ export class BotSpawner {
console.log("too many retries while spawning bots, giving up");
return this.bots;
}
const candidate = this.nextCandidateName();
const spawn = this.spawnBot(candidate.name);
const botName = this.randomBotName();
const spawn = this.spawnBot(botName);
if (spawn !== null) {
// Only use candidate name once bot successfully spawned
if (candidate.source === "list") {
this.nameIndex++;
}
this.bots.push(spawn);
} else {
tries++;
@@ -60,42 +51,10 @@ export class BotSpawner {
);
}
private nextCandidateName(): {
name: string;
source: "list" | "random";
} {
if (this.bots.length < 20) {
//first few usually overwritten by Nation spawn
return { name: this.getRandomElf(), source: "random" };
}
if (this.nameIndex < COMMUNITY_FULL_ELF_NAMES.length) {
return {
name: COMMUNITY_FULL_ELF_NAMES[this.nameIndex],
source: "list",
};
}
const specialOffset = COMMUNITY_FULL_ELF_NAMES.length;
if (this.nameIndex < specialOffset + SPECIAL_FULL_ELF_NAMES.length) {
return {
name: SPECIAL_FULL_ELF_NAMES[this.nameIndex - specialOffset],
source: "list",
};
}
const prefixOffset = specialOffset + SPECIAL_FULL_ELF_NAMES.length;
if (this.nameIndex < prefixOffset + COMMUNITY_PREFIXES.length) {
return {
name: `${COMMUNITY_PREFIXES[this.nameIndex - prefixOffset]} the Elf`,
source: "list",
};
}
return { name: this.getRandomElf(), source: "random" };
}
private getRandomElf(): string {
const suffixNumber = this.random.nextInt(1, 10001);
return `Elf ${suffixNumber}`;
private randomBotName(): string {
const prefixIndex = this.random.nextInt(0, BOT_NAME_PREFIXES.length);
const suffixIndex = this.random.nextInt(0, BOT_NAME_SUFFIXES.length);
return `${BOT_NAME_PREFIXES[prefixIndex]} ${BOT_NAME_SUFFIXES[suffixIndex]}`;
}
private randTile(): TileRef {