mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:50:43 +00:00
Simplify bots retaliation logic (#946)
## Description: Simplify bots retaliation logic. Do not counter-attack before reaching the trigger ratio. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [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 Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
committed by
evanpelle
parent
41481f190c
commit
00872e080a
@@ -79,7 +79,6 @@ export class BotExecution implements Execution {
|
||||
}
|
||||
|
||||
this.behavior.forgetOldEnemies();
|
||||
this.behavior.checkIncomingAttacks();
|
||||
const enemy = this.behavior.selectRandomEnemy();
|
||||
if (!enemy) return;
|
||||
if (!this.bot.sharesBorderWith(enemy)) return;
|
||||
|
||||
@@ -262,7 +262,6 @@ export class FakeHumanExecution implements Execution {
|
||||
throw new Error("not initialized");
|
||||
}
|
||||
this.behavior.forgetOldEnemies();
|
||||
this.behavior.checkIncomingAttacks();
|
||||
this.behavior.assistAllies();
|
||||
const enemy = this.behavior.selectEnemy();
|
||||
if (!enemy) return;
|
||||
|
||||
@@ -52,7 +52,7 @@ export class BotBehavior {
|
||||
}
|
||||
}
|
||||
|
||||
checkIncomingAttacks() {
|
||||
private checkIncomingAttacks() {
|
||||
// Switch enemies if we're under attack
|
||||
const incomingAttacks = this.player.incomingAttacks();
|
||||
if (incomingAttacks.length > 0) {
|
||||
@@ -109,6 +109,11 @@ export class BotBehavior {
|
||||
}
|
||||
}
|
||||
|
||||
// Retaliate against incoming attacks
|
||||
if (this.enemy === null) {
|
||||
this.checkIncomingAttacks();
|
||||
}
|
||||
|
||||
// Select the most hated player
|
||||
if (this.enemy === null) {
|
||||
const mostHated = this.player.allRelationsSorted()[0];
|
||||
@@ -145,8 +150,15 @@ export class BotBehavior {
|
||||
this.enemy = neighbor;
|
||||
this.enemyUpdated = this.game.ticks();
|
||||
}
|
||||
}
|
||||
|
||||
// Select a traitor as an enemy
|
||||
// Retaliate against incoming attacks
|
||||
if (this.enemy === null) {
|
||||
this.checkIncomingAttacks();
|
||||
}
|
||||
|
||||
// Select a traitor as an enemy
|
||||
if (this.enemy === null) {
|
||||
const traitors = this.player
|
||||
.neighbors()
|
||||
.filter((n) => n.isPlayer() && n.isTraitor()) as Player[];
|
||||
|
||||
Reference in New Issue
Block a user