Merge branch 'v26'

This commit is contained in:
evanpelle
2025-11-04 16:08:15 -08:00
37 changed files with 206 additions and 263 deletions
+37 -1
View File
@@ -58,7 +58,7 @@ export class PortExecution implements Execution {
return;
}
const ports = this.player.tradingPorts(this.port);
const ports = this.tradingPorts();
if (ports.length === 0) {
return;
@@ -103,4 +103,40 @@ export class PortExecution implements Execution {
}
}
}
// It's a probability list, so if an element appears twice it's because it's
// twice more likely to be picked later.
tradingPorts(): Unit[] {
const ports = this.mg
.players()
.filter((p) => p !== this.port!.owner() && p.canTrade(this.port!.owner()))
.flatMap((p) => p.units(UnitType.Port))
.sort((p1, p2) => {
return (
this.mg.manhattanDist(this.port!.tile(), p1.tile()) -
this.mg.manhattanDist(this.port!.tile(), p2.tile())
);
});
const weightedPorts: Unit[] = [];
for (const [i, otherPort] of ports.entries()) {
const expanded = new Array(otherPort.level()).fill(otherPort);
weightedPorts.push(...expanded);
const tooClose =
this.mg.manhattanDist(this.port!.tile(), otherPort.tile()) <
this.mg.config().tradeShipShortRangeDebuff();
const closeBonus =
i < this.mg.config().proximityBonusPortsNb(ports.length);
if (!tooClose && closeBonus) {
// If the port is close, but not too close, add it again
// to increase the chances of trading with it.
weightedPorts.push(...expanded);
}
if (!tooClose && this.port!.owner().isFriendly(otherPort.owner())) {
weightedPorts.push(...expanded);
}
}
return weightedPorts;
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ const EMOJI_ASSIST_ACCEPT = (["👍", "⛵", "🤝", "🎯"] as const).map(emoji
const EMOJI_RELATION_TOO_LOW = (["🥱", "🤦‍♂️"] as const).map(emojiId);
const EMOJI_TARGET_ME = (["🥺", "💀"] as const).map(emojiId);
const EMOJI_TARGET_ALLY = (["🕊️", "👎"] as const).map(emojiId);
export const EMOJI_HECKLE = (["👻", "🎃"] as const).map(emojiId);
export const EMOJI_HECKLE = (["🤡", "😡"] as const).map(emojiId);
export class BotBehavior {
private enemy: Player | null = null;