fix sendBoat() causing lag/freezes towards end game, add arrow emojis

This commit is contained in:
evanpelle
2024-10-05 11:35:40 -07:00
parent df28ee169f
commit 39d5e8d72f
4 changed files with 31 additions and 29 deletions
+8 -7
View File
@@ -149,12 +149,14 @@ export class FakeHumanExecution implements Execution {
}
}
sendBoat(tries: number = 0) {
if (tries > 100) {
sendBoat(tries: number = 0, oceanShore: Tile[] = null) {
if (tries > 10) {
return
}
const oceanShore = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
if (oceanShore == null) {
oceanShore = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
}
if (oceanShore.length == 0) {
return
}
@@ -171,7 +173,7 @@ export class FakeHumanExecution implements Execution {
return
}
for (let i = 0; i < 100; i++) {
for (let i = 0; i < 20; i++) {
const dst = this.random.randElement(otherShore)
if (this.isSmallIsland(dst)) {
continue
@@ -188,8 +190,7 @@ export class FakeHumanExecution implements Execution {
))
return
}
this.sendBoat(tries + 1)
this.sendBoat(tries + 1, oceanShore)
}
randomLand(): Tile {
@@ -216,7 +217,7 @@ export class FakeHumanExecution implements Execution {
}
isSmallIsland(tile: Tile): boolean {
return bfs(tile, and((t) => t.isLand(), dist(tile, 50))).size < 50
return bfs(tile, and((t) => t.isLand(), dist(tile, 10))).size < 50
}
owner(): MutablePlayer {