mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 01:29:47 +00:00
Merge branch 'v26'
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user