make bots more likely to attack larger border

This commit is contained in:
evanpelle
2024-08-29 20:19:56 -07:00
parent c8518ce30b
commit 0281db46fa
3 changed files with 26 additions and 19 deletions
+4 -1
View File
@@ -54,9 +54,12 @@
* BUG: players attack each other same time creates islands DONE 8/28/2024
* make bot spawn better DONE 8/28/2024
* make UX for attacking TerraNullius by boat better DONE 8/29/2024
* make bot territory less funky (more likely attack neighbors with larger border)
* make bot territory less funky (more likely attack neighbors with larger border) DONE 8/29/2024
* PERF: use hierarchical a* search for boats
* PERF: precompute spawns
* PERF: load terrain map async
* PERF: enable CDN
* enable load balancing metrics
* end game when no players left (or after 1 hour or so?)
* boats can go around the world
* Add terrain elevation to map
+1 -1
View File
@@ -19,7 +19,7 @@ export const devConfig = new class extends DefaultConfig {
return devPlayerConfig
}
numBots(): number {
return 50
return 250
}
}
+21 -17
View File
@@ -10,7 +10,7 @@ export class BotExecution implements Execution {
private random: PseudoRandom;
private attackRate: number
private mg: MutableGame
private neighborsTerra = true
private neighborsTerraNullius = true
constructor(private bot: MutablePlayer) {
@@ -37,26 +37,30 @@ export class BotExecution implements Execution {
return
}
if (ticks % this.attackRate == 0) {
if (this.neighborsTerra) {
for (const b of this.bot.borderTiles()) {
for (const n of b.neighbors()) {
if (n.owner() == this.mg.terraNullius() && n.isLand()) {
this.sendAttack(this.mg.terraNullius())
return
}
if (ticks % this.attackRate != 0) {
return
}
if (this.neighborsTerraNullius) {
for (const b of this.bot.borderTiles()) {
for (const n of b.neighbors()) {
if (n.owner() == this.mg.terraNullius() && n.isLand()) {
this.sendAttack(this.mg.terraNullius())
return
}
}
this.neighborsTerra = false
}
const ns = this.bot.neighbors()
if (ns.length == 0) {
return
}
const toAttack = ns[this.random.nextInt(0, ns.length)]
this.sendAttack(toAttack)
this.neighborsTerraNullius = false
}
const border = Array.from(this.bot.borderTiles()).flatMap(t => t.neighbors()).filter(t => t.hasOwner() && t.owner() != this.bot)
if (border.length == 0) {
return
}
const toAttack = border[this.random.nextInt(0, border.length)]
this.sendAttack(toAttack.owner())
}
sendAttack(toAttack: Player | TerraNullius) {