FightOptimizer.ash

therealtahu

New member
I notice that the Ash file is receiving updates, but not the data files, so will the original data files still work with new versions of the ash script? (Not really sure how that all works)

Yes, they will still work. However, most of the hp values in those have already been added into Mafia by default.

So here's the new semi update thing.
I've removed the haiku katana support for now, since it has been cluttering the file and I haven't been informed of how useful or useless my attempt was. I've updated part of the file to use the modifier data that mafia supplies, cut down on some extra parts, and mainly fooled around with the script. I haven't been able to test with every class, but I hope that most of these fixes work. It's also best to use the daily builds of mafia, since those are the most up to date, and hopefully will have the modifiers we need.

The instructions on the front page are a bit messed due to the forum change.
You're supposed to put this into your Custom Combat.
[ default ]
1: consult FightOptimizer.ash
Anyways, if there are any questions, issues or comments, you can either post in this topic or kmail me.

EDIT: Haiku Katana support has returned! It's still as unfinished as before though. But I think the +weapon damage % on the katana works now.

EDIT Part 2: The script runs slowly if you have a combat action bar. I recommend removing the bar, unless you want very slow page parsing.
 

Attachments

  • FightOptimizer.ash
    108 KB · Views: 116
Last edited:

dj_d

Member
Sorry TRH - I did use the katana support, it worked great! If you have a chance to re-introduce that'd be great.
 

therealtahu

New member
I've managed to finish up Winter's Bite attack and I think it works without any problems anymore. However, the haiku katana's attack is so hard to parse, and sometimes does not show the damage at all. In those cases, I guess I'll have to assume worst case scenario.

At the moment, I'm trying to get the Bandersnatch to work with this, and may start playing around with implementing familiars into the script.
 

Braska

Member
I am only having one problem when I try to use this script, and that is the speed.

Is anyone else experiencing MAJOR slow downs when using this? (I have never, and probably never will, used the Combat Action Bar)
 
Yeah, it's a cool idea, but it takes about 3 minutes per round of combat!!! I don't know why it's so slow, but that's pretty crazy!
 

Bale

Minion
And that is why the script hasn't been developed for quite a while. You're actually the first to post in this thread in the last 3 months. ;) It's a shame that zarqon's combat script can't do everything that this one can, but he might eventually finish his level 3 consult script which will do all this and more.
 

Braska

Member
I am wondering now, with the latest update to mafia which sped up eatdrink.ash and others, if this script will now run faster than it did before? If it still works that is...
 

Bale

Minion
That update will make ALL scripts run faster. It just has a greater effect on some scripts.
 

halfvoid

Member
It does in fact work. Still slower than casualcombat.ash but much more accurate and effective. I'm switchin back. Seems to fall on its face sometimes, at least when combined with smartstasis.ash and a pastamancer as smartstasis will use entangling noodles before fightoptimizer kicks in so it doesn't pick that as a strategy anymore on a high level monster and it'll leave you to fight the battle on your own.

hello run-on sentence.
 

Braska

Member
Maybe zarqon could give this script a look if there is time. Just to see if it can be made to be more compatible with SmartStasis. If there is no time it would be completely understandable, zarqon is one of the busiest scripters we have. :)

If I ever get the time to learn more about scripting for myself, I may try and change this myself. All I've really became competent with up to this point is changing other's scripts to work for me. And most of that is just me guessing if something will work, followed by either smiles or re-downloads >.>
 

Braska

Member
(Sorry for double post)

After reading and playing around with the script all night, I have come to the conclusion that this script is... messier... than most peoples. Thus, I have no idea how to correct the compatibility issues. It could be as simple as just turning off the entangling noodle portion of smartstasis until a better solution is found.

Also wondering what would happen if the script was changed so that it imported smartstasis at the beginning, before doing anything. It's probably a dumb idea, but if there is a chance it would make fightoptimizer realize that EN was already cast, it might be worth a shot.

Again, that will all take someone with way more scripting know-how than I to work on.
 
Now that there is a new profile function available, it's easier to find out why this script is so slow:

HTML:
Count   Total     Net   Name (sorted by net time)
19    289.807 289.807   group_string(string, string)
1     342.837  46.632   toplevel
4       6.045   6.045   attack()
45      0.271   0.086   simulate_strategy(int, int, string, boolean)
94      0.099   0.065   action_is_discouraged(string, int, int)
9     289.836   0.026   actual_action_damage(string)

group_string() is used 3 times per round. It looks like the main problem is when it uses the regex below to calculate the total damage against the opponent:
HTML:
((([ \t]+|<[^<>]+>|(&[A-Za-z]+;|&#[0-9]+;)|[()+])*[0-9]+([ \t]+|<[^<>]+>|(&[A-Za-z]+;|&#[0-9]+;)|[()+])*)+)[^0-9.]*(damage|to your opponent|points|notches)
on the full text of the page. One solution is to reduce the amount of text to search, e.g. by changing:
Code:
string[int,int] match = group_string(PAGE, damage_regex);
to:
Code:
int start = index_of(PAGE, "You're fighting");
int end = index_of(PAGE, "<div id='fightform'", start);
string[int,int] match = group_string(substring(PAGE, start, end), damage_regex);
With this change, and a couple of other tweaks, the script now takes less than a second per round, even with Combat action bars. I'm not sure how reliable this approach is though. How does Kolmafia calculate total damage?
 
Last edited:

Braska

Member
Not sure about that, we'll have to wait on a response from someone else. But is there anyway you could post your edited version so I could give it a spin? I'd just ask the line numbers, but really... as I said before... this script is just ugly to work with. (No offense to the creator(s))
 
Ok, I've attached the updated script. The main changes are from line 2255. I've also added Tango of Terror (does no one else use this?).

The script's not been extensively tested as I've ascended recently and I'm in HC.


Edit: This version of the script is obsolete, newer version in later post.
 

Attachments

  • FightOptimizer.ash
    108.6 KB · Views: 52
Last edited:

halfvoid

Member
i'll try it out tonight and let you know.

*update* seems to work slightly quicker and without any visible error. i've tried it out with a sauceror and a disco bandit thus far. both around level 15.
 
Last edited:
@halfvoid - only *slightly* quicker? Can you do a "view HTML source" on the fight page and see if it contains the text "You're fighting" followed by "<div id='fightform'" shortly after? If the script doesn't find them (in that order), it falls back to matching the damage regex against the whole page, which was what was so slow for me before.

Another possibility is that the optimiser is considering too many options. I have mostly passive and non-combat skills permed, so I wouldn't notice this being a problem. You can enable debug info by setting the debug flags on lines 80 and 81 to true, and looking at the output in the CLI window.

I've noticed that even when you can out-moxie the opponent, and hit it 100%, the optimiser will still search other strategies. Can you think of any occasion when another strategy would be more useful (apart from insults, gremlins, stasis and dictionary/scrolls in the chasm)?
 

xKiv

Active member
Can you think of any occasion when another strategy would be more useful (apart from insults, gremlins, stasis and dictionary/scrolls in the chasm)?

Yes. Killing the monster quickly (as opposed to plinking ~10 damage/round, which introduces higher risk of 1) being beaten up by monster criticals and self fumbles 2) not winning due to the 30-round limit)
 

therealtahu

New member
Not sure about that, we'll have to wait on a response from someone else. But is there anyway you could post your edited version so I could give it a spin? I'd just ask the line numbers, but really... as I said before... this script is just ugly to work with. (No offense to the creator(s))

It's been ugly for a long time, mostly because it was coded when we lacked easy functions for a ton of stuff. Large sections of the code probably need a major rewrite, especially the element handling. Back then, there weren't any elemental forms. As for my previous work on this, it was probably lost in a format some time ago.

Also, from the ashref, I can see that we have a ton of new functions for me to play around with.

EDIT: And I apparently get to play around with spell critical hit... Time to rewrite this to be a bit more modular.

Code:
int start = index_of(PAGE, "You're fighting");
int end = index_of(PAGE, "<div id='fightform'", start);
string[int,int] match = group_string(substring(PAGE, start, end), damage_regex);

This code would be great except for one thing. fightform doesn't show up if you don't use the CAB. I found that "<form name=attack" shows up on both.

While we're on the topic of regex, does anyone know how to use the new (at least to me) matcher thing? I figure that it would be easier than the group string thing in the script right now.
 
Last edited:

mredge73

Member
Matchers are not very difficult, they just take some testing.

Syntax help:
Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns

Test them here before using them in your script:
RegEx: online regular expression testing

Currently there are several scripts that use matchers, I use them to do all of my string parsing.

Cagebot.ash uses them, I learned how to do matchers from Alhifar:
http://kolmafia.us/showthread.php?t=1896&highlight=cagebot

My script are here, in my clan library I have one that uses a matcher to parse the clan members page:
http://kolmafia.us/showthread.php?t=2113

I don't mind helping update this script if you need any. This is the first time that I have actually looked at it so if there is a function that needs reworked point me in that direction. I want more experience in CCS.
 
Last edited:
Top