mrmin123 / kancolle-auto

Kantai Collection (Kancolle) bot/automation tool - DEPERECATED - see kcauto-kai:
https://github.com/mrmin123/kcauto-kai
54 stars 22 forks source link

Class-specific bucket use? #354

Closed R-Jimenez closed 7 years ago

R-Jimenez commented 7 years ago

This is a thought that just popped into my mind while doing some event-prep training. What kind of workflow would be required to place conditions on the bucket-use-timer?

As a use case, say I want to set my script to use buckets on any of my main ships if repairs exceed an hour, but for my sub tank I never want to use my bucket (set to 99 hours, etc.)

mrmin123 commented 7 years ago

When adding or modifying features to kancolle-auto just think of it like a huge, complex BDD-test. Distilled down, you need to figure out how a player who doesn't understand Japanese (because Sikuli/tesseract OCR doesn't understand Japanese) might do the thing you're trying to do.

For selecting whether or not the ship you're trying to repair should be bucketed or not depending on class, you would:

  1. Navigate to the repair screen
  2. Ascertain if there any open docks
  3. If step 2 is yes, you click one of them
  4. You look at the portrait image's ship class icon to determine the ship's class
  5. You look at the timer
  6. You click the bucket use switch depending on whether or not you want to use a bucket
  7. You click the Repair button in the sidebar
  8. You click the Confirm button in the subsequent step
  9. Repeat steps 1~8 for every ship you have left to repair

Step 4 is actually the only one not implemented, while step 6's logic will have to be modified to support this.

R-Jimenez commented 7 years ago

Thanks for the explanation! I knew of the process at a higher level, but it helps to have it spelled out. I should have a look at the code sometime and refresh myself on some python.

waicool20 commented 7 years ago

Hopefully you can code it in a way so it doesn't slow down the script too much. Scanning for multiple images takes up quite a lot of time.

R-Jimenez commented 7 years ago

I don't need to determine every class, just whether it is a sub or not (because subs are the only class with the ability to switch out, and therefore can be replaced in leveling fleets), so it would just be a pause between steps 3 and 5 to search for the sub class image.

My original idea was to simply specify the ship slot you have your sub, and only skip bucket repair on that slot, but that would require some caching of ship name through to the repair module.

waicool20 commented 7 years ago

@R-Jimenez Oh perfect, actually I'm working on this: https://github.com/waicool20/kancolle-auto/tree/fastSubSwitch

It's a faster implementation of the current sub switching module by caching which slots have subs and multithreaded image searching. Sadly it's not implemented in python :/ but it does have the caching that you need!

waicool20 commented 7 years ago

@mrmin123 Tesseract does have japanese if you install the tessdata for it...but I guess its accuracy is still something to desire.

R-Jimenez commented 7 years ago

@waicool20 Interesting. I took a look at your fork and all I see is Python though. :o What is it implemented in then?

waicool20 commented 7 years ago

@R-Jimenez https://github.com/waicool20/kancolle-auto/blob/fastSubSwitch/libs/KCSubSwitcher/src/main/kotlin/com/waicool20/kcsubswitcher/KCSubSwitcher.kt

Just take a look at the commits so you can see the changes next time.

R-Jimenez commented 7 years ago

I've returned and have some more time to properly spend going over the system. Is the subswitcher still something I should take a look at @waicool20?

waicool20 commented 7 years ago

Yes certainly, if it will help you achieve what you are trying to do.

R-Jimenez commented 7 years ago

Turns out it was a pretty simple solution. No external resources required, though your module definitely looks pretty. c:

I simply modified the bucket conditional code to include the search of the ship_class_ss and ship_class_ssv icons if a new configuration setting 'submarine_switch_use_buckets' was enabled. If the timer is below the normal use of a bucket or the setting isn't enabled, then there are no extra searches. Using min's workflow above, I only ended up needing to edit step 6 with an additional configuration check and image search.

I've tested the new cases (ship_class_ssv was trouble and had to be dropped to .65 similarity), so let me know how you want me to push the enhancement in.

waicool20 commented 7 years ago

Cool, glad it worked out for you. Might want to create a pull request then :p

I made sure to make my code look as good looking as it is efficient, cut down the sub switching time by half lol

mrmin123 commented 7 years ago

@R-Jimenez I reviewed your PR and requested some changes.

As for the caching of the sub page position, it's trivial to implement in the existing code without an additional Java module, but I didn't because ship drops might change the cached page location. If it's that big of a pain point I could make it so that it caches and checks at that page minus 1?

mrmin123 commented 7 years ago

PR is merged!