Skip to content

Commit

Permalink
Add on-the-fly minimum selection in energy game solving
Browse files Browse the repository at this point in the history
This trick from Brihaye & Goeminne (2023) has practically enabled better runtimes in https://github.com/Gobbel2000/gpuequiv/  (and also improves theoretical complexity.)
  • Loading branch information
benkeks committed Jun 26, 2024
1 parent feb68ee commit 94c635b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ trait EnergyGame extends SimpleGame with GameLazyDecision[EnergyGame.Energy] {
} yield attackerVictoryPrices(s).map(w.unapplyEnergyUpdate(_))
val productMoves =
possibleMoves.reduceLeft(
(b, a) => b.flatMap(i => a.map(j => i lub j)))
(b, a) => filterMinimal(b.flatMap(i => a.map(j => i lub j))))
productMoves.toSet
}
}

private def filterMinimal(energies: List[Energy]) = {
// if energy list becomes big, prune dominated energies on-the-fly at defender positions
// to prevent exponential blowup of options.
if (energies.size > 2) {
energies.filterNot(e1 => energies.exists(e2 => e2 < e1))
} else {
energies
}
}
}

object EnergyGame {
Expand Down

0 comments on commit 94c635b

Please sign in to comment.