Skip to content

Commit

Permalink
Debugging the battle back when ignoring flags
Browse files Browse the repository at this point in the history
  • Loading branch information
xpmatteo committed Nov 3, 2023
1 parent 57610ad commit f982c3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ image to appear. The parameters are:
* prune *n*: for the first *n* nodes in the tree, we only show the main line, not showing other subtrees
* iterations, playouts: configure AI parameters

# BUGS

Recently I tried to fix a bug: if a unit ignores flags and stays in its hex, it should battle back.

- now the AI is broken
- the retreat UI does not work correctly

# AI TESTS

- Early game
Expand Down
2 changes: 1 addition & 1 deletion src/model/commands/abstract_combat_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class AbstractCombatCommand extends Command {
if (attackingUnit.side === game.currentSide) {
game.unshiftPhase(new AdvanceAfterCombatPhase(defendingHex, game.hexOfUnit(attackingUnit)));
}
game.unshiftPhase(new RetreatPhase(attackingUnit, defendingUnit.side, defendingHex, flagResult.retreats));
game.unshiftPhase(new RetreatPhase(game.hexOfUnit(attackingUnit), defendingUnit.side, defendingHex, flagResult.retreats));
}
return events;
}
Expand Down
14 changes: 7 additions & 7 deletions src/model/phases/RetreatPhase.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import { IgnoreFlagAndBattleBackCommand } from "../commands/abstract_combat_comm
export class RetreatPhase extends Phase {
/**
* @param {Hex} attackingHex
* @param {Side} temporarySide
* @param {Hex} fromHex
* @param {Hex[]} toHexes
* @param {Side} defendingSide
* @param {Hex} defendingHex
* @param {Hex[]} retreatHexes
*/
constructor(attackingHex, temporarySide, fromHex, toHexes) {
constructor(attackingHex, defendingSide, defendingHex, retreatHexes) {
super("retreat");
this.attackingHex = attackingHex;
this.temporarySide = temporarySide;
this.fromHex = fromHex;
this.toHexes = toHexes;
this.temporarySide = defendingSide;
this.fromHex = defendingHex;
this.toHexes = retreatHexes;
}

validCommands(game) {
Expand Down

0 comments on commit f982c3d

Please sign in to comment.