Harry Crimboween
New member
Update - FightOptimizer 1.0.8 with preliminary support for NS13 changes has been posted. See below for details.
Here's something I've been working on for a little while now.
FightOptimizer.ash is a KoLmafia battle consult script which tries to beat whatever monster you're fighting with the fewest resources expended. It does this by looking at all the skills you have and your equipment and effects, then considering the tree of all possible strategies that you could use. Attack? Attack + Stream of Sauce? Attack + Stream of Sauce + Minor Ray of Something? Entangling Noodles + Attack? Lunging-Thrust Smack + Thrust-Smack? etc etc etc. Once it has explored the entire tree of strategies it picks the best one and uses it. ;D
How does it work? FO loops through all the possible strategies you can pursue. When considering a strategy, it actually simulates the whole battle round-by-round, estimating damage for monster attacks and player actions. By doing this it can find out whether a given strategy is a winning one, and it computes the cost in meat if it is. (Battles really have HP/MP costs, but those translate into meat easily enough.) It is pessimistic and assumes the worst in most cases, because you never know what the RNG is going to roll for you.
Isn't that slow? Not really. FO uses some clever techniques to trim the search space until it's manageable. It's fast enough that on my 2GHz laptop I barely even notice that it's running. Your mileage may vary depending on your CPU speed and Java VM.
Does it work? Oh yes. I've been using it for several ascensions on two different characters now, hardcore and softcore, and it can consistently beat all the monsters I've run into. And it either uses exactly the same strategy I would have used -- or a better one. In fact, I've been surprised a couple of times by FO's choice of strategy.
What about ML adjustments, ML variance, and scaling monsters? It handles ML adjustments beautifully. It is pessimistic about monster level variance -- it basically assumes the worst so that it never gets surprised. Scaling monsters (Feast of Boris, Baron von Ratsworth, Mob Penguins, etc) are special-cased in the script with the current best-guess formulae from the KoLwiki, so they work too.
Headbutt/Kneebutt/Shieldbutt? Head + Knee + Shield combos? Disco Bandit deleveling? Disco Combos? Yes, it's got at least preliminary support for all of those. The TT skills work well, but the DB skills and combos might need a bit more testing.
In-combat healing with Saucy Salve / Lasagna Bandages? I tried this out, but in practice it just expanded the search space exponentially and was really never worth it. If you look in the script you can try re-enabling them if you really want to.
Combat items? Not yet. It'll automatically use certain quest items and anti-anti-antidotes, but it does not consume damage-inflicting combat items. This may change in the future.
Stasis? Nope. I was considering adding it, but it sounds like it won't be worth the effort if NS13 nerfs it. We'll see, though -- some forms of stasis might still survive, such as starfish MP restoration.
Installation: FO currently requires KoLmafia 4235 or later. Drop FightOptimizer.ash into your "scripts" folder, and (optionally, but strongly recommended) drop the spading_hp_min.dat and spading_hp_max.dat files into your "data" folder.
Then go into the "Custom Combat" tab, hit Edit, and replace whatever's in there with this:
Many thanks to the people behind the KoLwiki, which was where most of the formulas and data tables used in this script were gathered from. And big thanks to the creators of KoLmafia and ASH. You know who you are.
Update - 1.0.2 - June 26 2007: I've added very early support for the NS13 changes. However, NS13 changed more than anybody expected, so ALL THE FORMULAS IN THE SCRIPT ARE PROBABLY WRONG NOW. But I've added at least early support for spell damage caps, chefstaff multipliers, and adjusted the TS/LTS hit percentages. Anything that's not explicitly stated in-game is just my own personal wild-ass guess. It also makes a very pessimistic assumption if it encounters a new, unspaded monster that KoLmafia doesn't yet know about. (It guesses that it's ML 200, so don't be surprised if it breaks out the big guns...) In short, it's highly experimental, and will sometimes just fail, but at least it's better than the old version at dealing with the post-NS13 world. I'll continue updating every few days as Mafia is updated and things are spaded out.
Update - 1.0.3 - June 27 2007: Got chefstaff stacking/dual-wielding working, added a number of monster element overrides.
Update - 1.0.4 - June 30 2007: Deal with spell backlash damage, which I think applies only to non-Myst classes. Also included handful of monster HP overrides for new monsters.
Update - 1.0.5 - July 2 2007: Added auto-spading of new monsters. To auto-spade, you'll need to download the *.dat files and put them in your scripts directory, then turn on the AUTOSPADE_MONSTERS configuration variable (and optionally AUTOSPADE_AGGRESSIVELY). Also tweaked the code to adjust the strategy during combat so that it should be a bit smarter.
Update - 1.0.6 - July 12 2007: Updated for changes to TS/LTS/Immaculate Seasoning. Added plinking when autospading. Added support for flyering, molybdenum magnet, and anti-anti-antidote during combat. Quite a few NS13 item updates.
Update - 1.0.7 - July 14 2007: Added support for outfit effects. Better handling of new/unspaded monsters - it used to sometimes get stuck on attacking when your hit stat is just too low, and now it tries to avoid that. Several changes to improve results on the Island Battlefield.
Update - 1.0.8 - July 15 2007: Fixed strategy updating, which had been broken by the anti-anti-antidote code. Myst is no longer your hit stat when using a staff with Rigatoni/SSG. Added Worm Wood monsters.
Here's something I've been working on for a little while now.
FightOptimizer.ash is a KoLmafia battle consult script which tries to beat whatever monster you're fighting with the fewest resources expended. It does this by looking at all the skills you have and your equipment and effects, then considering the tree of all possible strategies that you could use. Attack? Attack + Stream of Sauce? Attack + Stream of Sauce + Minor Ray of Something? Entangling Noodles + Attack? Lunging-Thrust Smack + Thrust-Smack? etc etc etc. Once it has explored the entire tree of strategies it picks the best one and uses it. ;D
How does it work? FO loops through all the possible strategies you can pursue. When considering a strategy, it actually simulates the whole battle round-by-round, estimating damage for monster attacks and player actions. By doing this it can find out whether a given strategy is a winning one, and it computes the cost in meat if it is. (Battles really have HP/MP costs, but those translate into meat easily enough.) It is pessimistic and assumes the worst in most cases, because you never know what the RNG is going to roll for you.
Isn't that slow? Not really. FO uses some clever techniques to trim the search space until it's manageable. It's fast enough that on my 2GHz laptop I barely even notice that it's running. Your mileage may vary depending on your CPU speed and Java VM.
Does it work? Oh yes. I've been using it for several ascensions on two different characters now, hardcore and softcore, and it can consistently beat all the monsters I've run into. And it either uses exactly the same strategy I would have used -- or a better one. In fact, I've been surprised a couple of times by FO's choice of strategy.
[li]Example #1: Adventuring in the Goatlet, I would often use the spellslinging strategy of Entangling Noodles, Stream of Sauce, Stream of Sauce (9MP) if I were doing things manually. FightOptimizer saw that in certain cases that could be replaced by Entangling Noodles, attack, Stream of Sauce (6MP) and did so. Cool!
[/li]
[li]Example #2: Adventuring in the Castle in the Clouds in the Sky as a muscle class, I would often use LTS or Noodles + high-level spells when I was doing things manually. But as soon as I acquired Cannelloni Cocoon, FO decided that in some cases it would be cheaper to simply attack giants in the Castle in the Clouds in the Sky and take damage from them (getting beaten to within an inch of my life) and then cast CC to restore my HP after the battle was done. Whoa. But it was absolutely right.
[/li]
[li]Example #3: Once, with a softcore character fighting in the hedge maze, I noticed that FO was choosing some seriously high-level expensive skills to defeat the Topiary Golems. (Weapon of the Pastalord, Fearful Fettucini, etc.) I stopped the script and investigated. Whoops, it turns out that I'd accidentally gone there totally naked, wearing nothing at all... no spell bonuses, no melee bonuses, no damage reduction, not even a weapon. FO had noticed this and was still managing to trounce the golems anyway, although at a much higher cost in MP of course.
[/li]
[li]Example #4: FO will even adjust its strategy in the middle of a fight if your attacks do more damage than its pessimistic prediction. In the Orc Chasm, you often see things like this:
Request 22 of 314 (Mountain: Valley Beyond Orc Chasm) in progress...
Encounter: Flaming Troll
Internally representing encounter as Flaming Troll...
Strategy: custom combat script
Round 0: Harry Crimboween wins initiative!
FightOptimizer strategy: Entangling Noodles, dictionary, Stream of Sauce (36 meat)
Round 1: Harry Crimboween casts ENTANGLING NOODLES!
Round 2: Harry Crimboween uses the dictionary!
You did 50 damage with your dictionary. (p=30)
FightOptimizer adjusted strategy: dictionary (18 meat)
Round 3: Harry Crimboween uses the dictionary!
You did 41 damage with your dictionary. (p=30)
You win the fight!
[/li]
What about ML adjustments, ML variance, and scaling monsters? It handles ML adjustments beautifully. It is pessimistic about monster level variance -- it basically assumes the worst so that it never gets surprised. Scaling monsters (Feast of Boris, Baron von Ratsworth, Mob Penguins, etc) are special-cased in the script with the current best-guess formulae from the KoLwiki, so they work too.
Headbutt/Kneebutt/Shieldbutt? Head + Knee + Shield combos? Disco Bandit deleveling? Disco Combos? Yes, it's got at least preliminary support for all of those. The TT skills work well, but the DB skills and combos might need a bit more testing.
In-combat healing with Saucy Salve / Lasagna Bandages? I tried this out, but in practice it just expanded the search space exponentially and was really never worth it. If you look in the script you can try re-enabling them if you really want to.
Combat items? Not yet. It'll automatically use certain quest items and anti-anti-antidotes, but it does not consume damage-inflicting combat items. This may change in the future.
Stasis? Nope. I was considering adding it, but it sounds like it won't be worth the effort if NS13 nerfs it. We'll see, though -- some forms of stasis might still survive, such as starfish MP restoration.
Installation: FO currently requires KoLmafia 4235 or later. Drop FightOptimizer.ash into your "scripts" folder, and (optionally, but strongly recommended) drop the spading_hp_min.dat and spading_hp_max.dat files into your "data" folder.
Then go into the "Custom Combat" tab, hit Edit, and replace whatever's in there with this:
[pre][ default ]
1: consult FightOptimizer.ash
[/pre]
Many thanks to the people behind the KoLwiki, which was where most of the formulas and data tables used in this script were gathered from. And big thanks to the creators of KoLmafia and ASH. You know who you are.

Update - 1.0.2 - June 26 2007: I've added very early support for the NS13 changes. However, NS13 changed more than anybody expected, so ALL THE FORMULAS IN THE SCRIPT ARE PROBABLY WRONG NOW. But I've added at least early support for spell damage caps, chefstaff multipliers, and adjusted the TS/LTS hit percentages. Anything that's not explicitly stated in-game is just my own personal wild-ass guess. It also makes a very pessimistic assumption if it encounters a new, unspaded monster that KoLmafia doesn't yet know about. (It guesses that it's ML 200, so don't be surprised if it breaks out the big guns...) In short, it's highly experimental, and will sometimes just fail, but at least it's better than the old version at dealing with the post-NS13 world. I'll continue updating every few days as Mafia is updated and things are spaded out.
Update - 1.0.3 - June 27 2007: Got chefstaff stacking/dual-wielding working, added a number of monster element overrides.
Update - 1.0.4 - June 30 2007: Deal with spell backlash damage, which I think applies only to non-Myst classes. Also included handful of monster HP overrides for new monsters.
Update - 1.0.5 - July 2 2007: Added auto-spading of new monsters. To auto-spade, you'll need to download the *.dat files and put them in your scripts directory, then turn on the AUTOSPADE_MONSTERS configuration variable (and optionally AUTOSPADE_AGGRESSIVELY). Also tweaked the code to adjust the strategy during combat so that it should be a bit smarter.
Update - 1.0.6 - July 12 2007: Updated for changes to TS/LTS/Immaculate Seasoning. Added plinking when autospading. Added support for flyering, molybdenum magnet, and anti-anti-antidote during combat. Quite a few NS13 item updates.
Update - 1.0.7 - July 14 2007: Added support for outfit effects. Better handling of new/unspaded monsters - it used to sometimes get stuck on attacking when your hit stat is just too low, and now it tries to avoid that. Several changes to improve results on the Island Battlefield.
Update - 1.0.8 - July 15 2007: Fixed strategy updating, which had been broken by the anti-anti-antidote code. Myst is no longer your hit stat when using a staff with Rigatoni/SSG. Added Worm Wood monsters.