Multi src astar (#594)

## Description:
Samples border shore tiles and uses multi-a* for determining the
transport ship spawn cell.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

<DISCORD USERNAME>
evan

---------

Co-authored-by: evan <openfrontio@gmail.com>
This commit is contained in:
evanpelle
2025-04-23 10:16:43 -07:00
committed by GitHub
parent b2c3a8add6
commit 84287b8dfa
14 changed files with 167 additions and 126 deletions
+5 -1
View File
@@ -65,12 +65,16 @@ export class Executor {
this.mg.ref(intent.x, intent.y),
);
case "boat":
let src = null;
if (intent.srcX != null || intent.srcY != null) {
src = this.mg.ref(intent.srcX, intent.srcY);
}
return new TransportShipExecution(
playerID,
intent.targetID,
this.mg.ref(intent.dstX, intent.dstY),
intent.troops,
this.mg.ref(intent.srcX, intent.srcY),
src,
);
case "allianceRequest":
return new AllianceRequestExecution(playerID, intent.recipient);
+1 -1
View File
@@ -50,7 +50,7 @@ export class MirvExecution implements Execution {
this.random = new PseudoRandom(mg.ticks() + simpleHash(this.senderID));
this.mg = mg;
this.pathFinder = PathFinder.Mini(mg, 10_000, true);
this.pathFinder = PathFinder.Mini(mg, 10_000);
this.player = mg.player(this.senderID);
this.targetPlayer = this.mg.owner(this.dst);
+1 -1
View File
@@ -76,7 +76,7 @@ export class PortExecution implements Execution {
}
const port = this.random.randElement(ports);
const pf = PathFinder.Mini(this.mg, 2500, false);
const pf = PathFinder.Mini(this.mg, 2500);
this.mg.addExecution(
new TradeShipExecution(this.player().id(), this.port, port, pf),
);
+1 -1
View File
@@ -26,7 +26,7 @@ export class SAMMissileExecution implements Execution {
) {}
init(mg: Game, ticks: number): void {
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10);
this.pathFinder = PathFinder.Mini(mg, 2000, 10);
this.mg = mg;
}
+1 -1
View File
@@ -19,7 +19,7 @@ export class ShellExecution implements Execution {
) {}
init(mg: Game, ticks: number): void {
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10);
this.pathFinder = PathFinder.Mini(mg, 2000, 10);
this.mg = mg;
}
+11 -1
View File
@@ -64,7 +64,7 @@ export class TransportShipExecution implements Execution {
this.lastMove = ticks;
this.mg = mg;
this.pathFinder = PathFinder.Mini(mg, 10_000, false, 10);
this.pathFinder = PathFinder.Mini(mg, 10_000, 10);
this.attacker = mg.player(this.attackerID);
@@ -128,6 +128,16 @@ export class TransportShipExecution implements Execution {
// Only update the src if it's not already set
// because we assume that the src is set to the best spawn tile
this.src = closestTileSrc;
} else {
if (
this.mg.owner(this.src) != this.attacker ||
!this.mg.isShore(this.src)
) {
console.warn(
`src is not a shore tile or not owned by: ${this.attacker.name()}`,
);
this.src = closestTileSrc;
}
}
this.boat = this.attacker.buildUnit(
+1 -1
View File
@@ -40,7 +40,7 @@ export class WarshipExecution implements Execution {
this.active = false;
return;
}
this.pathfinder = PathFinder.Mini(mg, 5000, false);
this.pathfinder = PathFinder.Mini(mg, 5000);
this._owner = mg.player(this.playerID);
this.mg = mg;
this.patrolTile = this.patrolCenterTile;