Revert "Improve random spawn (#2465)"

This reverts commit 2b2200c808.
This commit is contained in:
evanpelle
2025-11-19 10:58:49 -08:00
parent 0ba709c40d
commit 807151b723
9 changed files with 19 additions and 71 deletions
-1
View File
@@ -153,7 +153,6 @@ export interface Config {
defensePostRange(): number;
SAMCooldown(): number;
SiloCooldown(): number;
minDistanceBetweenPlayers(): number;
defensePostDefenseBonus(): number;
defensePostSpeedBonus(): number;
falloutDefenseModifier(percentOfFallout: number): number;
-3
View File
@@ -618,9 +618,6 @@ export class DefaultConfig implements Config {
temporaryEmbargoDuration(): Tick {
return 300 * 10; // 5 minutes.
}
minDistanceBetweenPlayers(): number {
return 30;
}
percentageTilesOwnedToWin(): number {
if (this._gameConfig.gameMode === GameMode.Team) {
+6 -24
View File
@@ -40,33 +40,15 @@ export class BotSpawner {
if (!this.gs.isLand(tile)) {
return null;
}
const isOtherPlayerSpawnedNearby = this.gs.allPlayers().some((player) => {
const spawnTile = player.spawnTile();
if (spawnTile === undefined) {
return false;
for (const spawn of this.bots) {
if (this.gs.manhattanDist(spawn.tile, tile) < 30) {
return null;
}
return (
this.gs.manhattanDist(spawnTile, tile) <
this.gs.config().minDistanceBetweenPlayers()
);
});
if (isOtherPlayerSpawnedNearby) {
return null;
}
const playerInfo = new PlayerInfo(
botName,
PlayerType.Bot,
null,
this.random.nextID(),
return new SpawnExecution(
new PlayerInfo(botName, PlayerType.Bot, null, this.random.nextID()),
tile,
);
this.gs.addPlayer(playerInfo).setSpawnTile(tile);
return new SpawnExecution(playerInfo, tile);
}
private randomBotName(): string {
+2 -2
View File
@@ -128,11 +128,11 @@ export class Executor {
}
}
spawnBots(numBots: number): SpawnExecution[] {
spawnBots(numBots: number): Execution[] {
return new BotSpawner(this.mg, this.gameID).spawnBots(numBots);
}
spawnPlayers(): SpawnExecution[] {
spawnPlayers(): Execution[] {
return new PlayerSpawner(this.mg, this.gameID).spawnPlayers();
}
-19
View File
@@ -159,7 +159,6 @@ export class FakeHumanExecution implements Execution {
console.warn(`cannot spawn ${this.nation.playerInfo.name}`);
return;
}
this.mg.addPlayer(this.nation.playerInfo).setSpawnTile(rl);
this.mg.addExecution(new SpawnExecution(this.nation.playerInfo, rl));
return;
}
@@ -644,24 +643,6 @@ export class FakeHumanExecution implements Execution {
continue;
}
const tile = this.mg.ref(x, y);
const isOtherPlayerSpawnedNearby = this.mg.allPlayers().some((player) => {
const spawnTile = player.spawnTile();
if (spawnTile === undefined) {
return false;
}
return (
this.mg.manhattanDist(spawnTile, tile) <
this.mg.config().minDistanceBetweenPlayers()
);
});
if (isOtherPlayerSpawnedNearby) {
continue;
}
if (this.mg.isLand(tile) && !this.mg.hasOwner(tile)) {
if (
this.mg.terrainType(tile) === TerrainType.Mountain &&
-5
View File
@@ -48,11 +48,6 @@ export class SpawnExecution implements Execution {
this.mg.addExecution(new BotExecution(player));
}
}
if (player.spawnTile() === undefined) {
player.setSpawnTile(this.tile);
}
player.setHasSpawned(true);
}
+11 -6
View File
@@ -9,6 +9,7 @@ export class PlayerSpawner {
private random: PseudoRandom;
private players: SpawnExecution[] = [];
private static readonly MAX_SPAWN_TRIES = 10_000;
private static readonly MIN_SPAWN_DISTANCE = 30;
constructor(
private gm: Game,
@@ -40,13 +41,18 @@ export class PlayerSpawner {
continue;
}
const isOtherPlayerSpawnedNearby = this.players.some(
(spawn) =>
let tooCloseToOtherPlayer = false;
for (const spawn of this.players) {
if (
this.gm.manhattanDist(spawn.tile, tile) <
this.gm.config().minDistanceBetweenPlayers(),
);
PlayerSpawner.MIN_SPAWN_DISTANCE
) {
tooCloseToOtherPlayer = true;
break;
}
}
if (isOtherPlayerSpawnedNearby) {
if (tooCloseToOtherPlayer) {
continue;
}
@@ -69,7 +75,6 @@ export class PlayerSpawner {
continue;
}
player.setSpawnTile(spawnLand);
this.players.push(new SpawnExecution(player.info(), spawnLand));
}
-2
View File
@@ -547,8 +547,6 @@ export interface Player {
hasSpawned(): boolean;
setHasSpawned(hasSpawned: boolean): void;
setSpawnTile(spawnTile: TileRef): void;
spawnTile(): TileRef | undefined;
// Territory
tiles(): ReadonlySet<TileRef>;
-9
View File
@@ -102,7 +102,6 @@ export class PlayerImpl implements Player {
public _outgoingLandAttacks: Attack[] = [];
private _hasSpawned = false;
private _spawnTile: TileRef | undefined;
private _isDisconnected = false;
constructor(
@@ -348,14 +347,6 @@ export class PlayerImpl implements Player {
this._hasSpawned = hasSpawned;
}
setSpawnTile(spawnTile: TileRef): void {
this._spawnTile = spawnTile;
}
spawnTile(): TileRef | undefined {
return this._spawnTile;
}
incomingAllianceRequests(): AllianceRequest[] {
return this.mg.allianceRequests.filter((ar) => ar.recipient() === this);
}