* deleted old maps

* fixed bug where NPC and Bots had same id
* NPCs spawn near IRL location
* NPCs have different strength (starting troops)
* game has more NPCs than before
* Needs more balancing
This commit is contained in:
evanpelle
2024-10-08 20:42:35 -07:00
parent 4059b53904
commit 7235b73b6c
13 changed files with 87 additions and 31 deletions
+10 -7
View File
@@ -26,7 +26,8 @@ export class Executor {
private random: PseudoRandom = null
constructor(private gs: Game, private gameID: GameID) {
this.random = new PseudoRandom(simpleHash(gameID))
// Add one to avoid id collisions with bots.
this.random = new PseudoRandom(simpleHash(gameID) + 1)
}
createExecs(turn: Turn): Execution[] {
@@ -86,15 +87,17 @@ export class Executor {
fakeHumanExecutions(numFakes: number): Execution[] {
const execs = []
for (let i = 0; i < numFakes; i++) {
execs.push(
new FakeHumanExecution(new PlayerInfo(
this.usernames[this.random.nextInt(0, this.usernames.length)],
for (const nation of this.gs.nations()) {
execs.push(new FakeHumanExecution(
new PlayerInfo(
nation.name,
PlayerType.FakeHuman,
null,
this.random.nextID()
))
)
),
nation.cell,
nation.strength
))
}
return execs
}
+12 -3
View File
@@ -21,7 +21,7 @@ export class FakeHumanExecution implements Execution {
private isTraitor = false
constructor(private playerInfo: PlayerInfo) {
constructor(private playerInfo: PlayerInfo, private cell: Cell, private strength: number) {
this.random = new PseudoRandom(simpleHash(playerInfo.id))
}
@@ -41,12 +41,14 @@ export class FakeHumanExecution implements Execution {
this.randomLand().cell()
))
}
return
}
if (this.player == null) {
this.player = this.mg.players().find(p => p.id() == this.playerInfo.id)
if (this.player == null) {
//console.log(`player with id ${this.playerInfo.id} not found in FakeHumanExecution`)
return
} else {
this.player.setTroops(this.player.troops() * this.strength)
}
}
@@ -194,8 +196,15 @@ export class FakeHumanExecution implements Execution {
}
randomLand(): Tile {
const delta = 25
while (true) {
const cell = new Cell(this.random.nextInt(0, this.mg.width()), this.random.nextInt(0, this.mg.height()))
const cell = new Cell(
this.random.nextInt(this.cell.x - delta, this.cell.x + delta),
this.random.nextInt(this.cell.y - delta, this.cell.y + delta)
)
if (!this.mg.isOnMap(cell)) {
continue
}
const tile = this.mg.tile(cell)
if (tile.isLand() && !tile.hasOwner()) {
if (tile.terrain() == TerrainType.Mountain && this.random.chance(2)) {