simply start population calculation

This commit is contained in:
Evan
2025-02-03 12:37:04 -08:00
parent c109d23f9f
commit bbf72bd14f
7 changed files with 36 additions and 45 deletions
+4 -7
View File
@@ -155,6 +155,7 @@ export class Executor {
fakeHumanExecutions(): Execution[] {
const execs = [];
for (const nation of this.mg.nations()) {
console.log(`got nation: ${nation.name}`);
execs.push(
new FakeHumanExecution(
this.gameID,
@@ -162,13 +163,9 @@ export class Executor {
nation.name,
PlayerType.FakeHuman,
null,
this.random.nextID()
),
nation.cell,
nation.strength *
this.mg
.config()
.difficultyModifier(this.mg.config().gameConfig().difficulty)
this.random.nextID(),
nation
)
)
);
}
+4 -10
View File
@@ -43,12 +43,7 @@ export class FakeHumanExecution implements Execution {
private lastEnemyUpdateTick: number = 0;
private lastEmojiSent = new Map<Player, Tick>();
constructor(
gameID: GameID,
private playerInfo: PlayerInfo,
private cell: Cell,
private strength: number
) {
constructor(gameID: GameID, private playerInfo: PlayerInfo) {
this.random = new PseudoRandom(
simpleHash(playerInfo.id) + simpleHash(gameID)
);
@@ -77,8 +72,6 @@ export class FakeHumanExecution implements Execution {
this.player = this.mg.players().find((p) => p.id() == this.playerInfo.id);
if (this.player == null) {
return;
} else {
this.player.setTroops(this.player.troops() * this.strength);
}
}
if (this.firstMove) {
@@ -522,8 +515,9 @@ export class FakeHumanExecution implements Execution {
let tries = 0;
while (tries < 50) {
tries++;
const x = this.random.nextInt(this.cell.x - delta, this.cell.x + delta);
const y = this.random.nextInt(this.cell.y - delta, this.cell.y + delta);
const cell = this.playerInfo.nation.cell;
const x = this.random.nextInt(cell.x - delta, cell.x + delta);
const y = this.random.nextInt(cell.y - delta, cell.y + delta);
if (!this.mg.isValidCoord(x, y)) {
continue;
}