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

Issue with formation selection + resupplying 2nd fleet #166

Closed Aftersky closed 8 years ago

Aftersky commented 8 years ago

Environment details

Is the issue consistent (can be reproduced consistently) or is it transient (only happens sometimes)? Please check one of the boxes:

Kancolle auto often stop at formation selection screen, it doesn't attempt to select a formation and just waited indefinitely without crashing.

My speculation after a little testing in E3 and 1-5 map: the script always fail to select a formation after reaching the second combat node in these maps, possibly because it was expecting a compass spin instead of fleet selection but there isn't one.

Console log (if applicable)

E3 Sample (combined fleet):

[2016-05-13 01:55:42] Commencing sortie!
[log] CLICK on L(691,532)@S(0)[0,0 1366x768]
[log] CLICK on L(347,454)@S(0)[0,0 1366x768]
[log] CLICK on L(347,454)@S(0)[0,0 1366x768]
[2016-05-13 01:56:08] Spinning compass!
[log] CLICK on L(706,399)@S(0)[0,0 1366x768]
[2016-05-13 01:56:18] Selecting fleet formation!
[log] CLICK on L(711,128)@S(0)[0,0 1366x768]
[2016-05-13 01:57:56] Checking fleet condition...
[2016-05-13 01:58:02] Light damage: 1; moderate damage: 0; critical damage:
 0
[log] CLICK on L(275,138)@S(0)[0,0 1366x768]
[2016-05-13 01:58:08] Checking fleet condition...
[2016-05-13 01:58:12] Light damage: 3; moderate damage: 1; critical damage:
 0
[log] CLICK on L(534,345)@S(0)[0,0 1366x768]
[log] CLICK on L(279,312)@S(0)[0,0 1366x768]

1-5 Sample:

[2016-05-13 02:11:13] Commencing sortie!
[log] CLICK on L(674,549)@S(0)[0,0 1366x768]
[log] CLICK on L(615,427)@S(0)[0,0 1366x768]
[2016-05-13 02:11:40] Selecting fleet formation!
[log] CLICK on L(250,307)@S(0)[0,0 1366x768]
[2016-05-13 02:12:50] Checking fleet condition...
[2016-05-13 02:12:59] Light damage: 0; moderate damage: 0; critical damage:
 0
[log] CLICK on L(747,143)@S(0)[0,0 1366x768]
[log] CLICK on L(371,408)@S(0)[0,0 1366x768]
[log] CLICK on L(607,283)@S(0)[0,0 1366x768]
[log] CLICK on L(309,341)@S(0)[0,0 1366x768]
Aftersky commented 8 years ago

Instead of opening another issue I'll just add this here: kancolle auto consistently have trouble resupplying the 2nd fleet in combined fleet mode, it will keep clicking the 2nd fleet switch a million times. Maybe it has something to do with the smoke fix @mrmin123 added in last commit.

https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/resupply.webm

[log] CLICK on L(190,203)@S(0)[0,0 1366x768]
[log] CLICK on L(186,202)@S(0)[0,0 1366x768]
[log] CLICK on L(181,197)@S(0)[0,0 1366x768]
[log] CLICK on L(182,209)@S(0)[0,0 1366x768]
[log] CLICK on L(181,200)@S(0)[0,0 1366x768]
[log] CLICK on L(185,202)@S(0)[0,0 1366x768]
[log] CLICK on L(188,203)@S(0)[0,0 1366x768]
[log] CLICK on L(188,205)@S(0)[0,0 1366x768]
........
mrmin123 commented 8 years ago

Regarding the second (resupply) issue. That's definitely related to the smoke fix. The script now checks for an exact match of the green flag to know that it's selected the correct fleet, and I'm thinking that the '+' in the combined fleet text runs into the exact matching area. I'm guessing that if you change the .exact() to .similar(0.95) or .similar(0.9) it should work..? If you go too low, however, you risk the chance of kancolle-auto assuming that you're on the right fleet even if it's not and being stuck in a resupply loop.

First issue I need to look at the code a bit more.

On Thu, May 12, 2016 at 10:59 AM, Aftersky notifications@github.com wrote:

Instead of opening another issue I'll just add this here: kancolle auto seems to have trouble resupplying the 2nd fleet in combined fleet mode, it will keep clicking the 2nd fleet switch a million times. Maybe it has to do with the smoke fix @mrmin123 https://github.com/mrmin123 added in last commit.

https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/resupply.webm

[log] CLICK on L(190,203)@S(0)[0,0 1366x768] [log] CLICK on L(186,202)@S(0)[0,0 1366x768] [log] CLICK on L(181,197)@S(0)[0,0 1366x768] [log] CLICK on L(182,209)@S(0)[0,0 1366x768] [log] CLICK on L(181,200)@S(0)[0,0 1366x768] [log] CLICK on L(185,202)@S(0)[0,0 1366x768] [log] CLICK on L(188,203)@S(0)[0,0 1366x768] [log] CLICK on L(188,205)@S(0)[0,0 1366x768] ........

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/mrmin123/kancolle-auto/issues/166#issuecomment-218836497

Aftersky commented 8 years ago

Thanks, changing .exact() to .similar(0.95) worked.

Also, there's one more issue I just remembered to bring up: morale check hasn't been working properly since one of the commit that added winter event support. More often than not kancolle auto will sortie even if the fleet morale is red and morale check enabled.

Changing similar(0.98) to .exact() in combat.py doesn't seem to do anything.

mrmin123 commented 8 years ago

@Aftersky Could you provide a screenshot of a combined fleet with low morale on the pre-sortie screen (where morale check is done)?

mrmin123 commented 8 years ago

Actually, I just noticed that you didn't mention combined fleet for morale check. I saw morale check work on orel just last night...

Aftersky commented 8 years ago

@mrmin123 I'll record a webm after maintenance. It's not a specific issue with combined fleet but regular fleet as well although I haven't tried again with regular fleet after changing similar(0.98) to .exact(). Usually kancolle will just fail the morale check and start combat but occasionally it does work.

I've had this issue for months with all kancolle auto versions post Winter event so I've resorted to using an older build for Orel farming.

mrmin123 commented 8 years ago

@Aftersky Does the version you use still have this block of code in combat.py or something similar?

    def fatigue_check(self):
        log_msg("Checking fleet morale!")
        if global_regions['check_morale'].exists(Pattern('fatigue_high.png').similar(0.98)):
            log_warning("Ship(s) with high fatigue found!")
            return 24
        elif global_regions['check_morale'].exists(Pattern('fatigue_med.png').similar(0.98)):
            log_warning("Ship(s) with medium fatigue found!")
            return 12
        else:
            log_success("Ships have good morale!")
            return None

Could you post it in here? The only thing I remember changing is using global_regions['check_morale'] instead of kc_region

Aftersky commented 8 years ago

This is in the old version I'm using:

    def fatigue_check(self):
        log_msg("Checking fleet morale!")
        if self.kc_window.exists(Pattern('fatigue_high.png').similar(0.98)):
            log_warning("Ship(s) with high fatigue found!")
            return 24
        elif self.kc_window.exists(Pattern('fatigue_med.png').similar(0.98)):
            log_warning("Ship(s) with medium fatigue found!")
            return 12
        else:
            log_success("Ships have good morale!")
            return None
mrmin123 commented 8 years ago

The only difference is that instead of checking the whole screen, I defined a subregion of the screen that should contain the morale icons for faster checks. The currently defined area is:

global_regions['check_morale'] = Region(util_settings['game_x'] + 500, util_settings['game_y'] + 135, 22, 290)

So, relative to the upper-left corner of the game window (not the app window), 500 pixels to the right and 135 pixels down, and from there, the region 22 pixels right and 290 pixels down. If you find that the morale icons in your game fall outside of this region (which I don't expect) that would be the cause of the issue. You could also try expanding the areas defined in util.py to see if you get better results. Maybe something like:

global_regions['check_morale'] = Region(util_settings['game_x'] + 480, util_settings['game_y'] + 100, 62, 350)
Aftersky commented 8 years ago

I wasn't able to reproduce the morale issue at all today despite getting it a lot yesterday, so maybe it only happen under certain condition. I will try to observe it some more.

Here is the issue with formation selection screen, it always happen at E3 and 1-5 second combat node, I haven't tried other maps yet:

https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/e3.webm

Aftersky commented 8 years ago

@mrmin123 Screen resolution may be the cause, normally I run kancolle auto in fullscreen browser mode but this time I adjusted it a bit in windowed mode to show part of the Command Prompt and there wasn't any problem with morale check.

mrmin123 commented 8 years ago

@Aftersky moving the game window/resizing during the kancolle-auto runtime can create some issues, yes, because the way the global regions are defined (only periodically)

For the formation select issue, I'll have to look into it a bit more... I looked at the logic last night and couldn't find anything obvious. Could you post the Combat configs, as well?

Aftersky commented 8 years ago

https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/maximized.webm

You were right, screen resolution is the cause. I always start the script after moving/resizing the window though, not while it is running. In this case it probably is because KC3 DMM frame mode having some space to the left of the game screen, this space is smaller when I resized the browser window in earlier test so there weren't any issue.

Config file: https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/config.ini (reuploaded, please check again)

Thank you for the help.

n0k0m3 commented 8 years ago

Did the problem carry from old ver or just from the latest commit? On May 13, 2016 2:59 AM, "Aftersky" notifications@github.com wrote:

Instead of opening another issue I'll just add this here: kancolle auto seems to have trouble resupplying the 2nd fleet in combined fleet mode, it will keep clicking the 2nd fleet switch a million times. Maybe it has to do with the smoke fix @mrmin123 https://github.com/mrmin123 added in last commit.

https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/resupply.webm

[log] CLICK on L(190,203)@S(0)[0,0 1366x768] [log] CLICK on L(186,202)@S(0)[0,0 1366x768] [log] CLICK on L(181,197)@S(0)[0,0 1366x768] [log] CLICK on L(182,209)@S(0)[0,0 1366x768] [log] CLICK on L(181,200)@S(0)[0,0 1366x768] [log] CLICK on L(185,202)@S(0)[0,0 1366x768] [log] CLICK on L(188,203)@S(0)[0,0 1366x768] [log] CLICK on L(188,205)@S(0)[0,0 1366x768] ........

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/mrmin123/kancolle-auto/issues/166#issuecomment-218836497

Aftersky commented 8 years ago

@minh6a It is from the latest commit, relating to the smoke fix. mrmin123 suggested a fix in https://github.com/mrmin123/kancolle-auto/issues/166#issuecomment-218840362

mrmin123 commented 8 years ago

The fix is also in the branch more_may_updates which will be merged in later today after some additional fixes.

@Aftersky the formation issue is because you set 2 nodes, but only one formation. kancolle-auto currently naively selects line_ahead for the remaining node, which will never show on a combined fleet map. I'm going to fix it later so that it properly sets the correct formation depending on combined fleet status, but until then please specify the formation for each node.

Aftersky commented 8 years ago

@mrmin123 Thank you, I keep forgetting to add more nodes formation after duplicating the 3-2-A config. All issues are resolved!

Aftersky commented 8 years ago

@mrmin123 Do you think there is a problem with formation selection when there is only 4 formations available due to the fleet having less than 6 ships? I'm still experiencing this issue in Orel with 4 subs fleet and I've made sure to set formation for every node this time.

Edit: nevermind, that's probably not it. Kancolle auto was able to select a formation with 4 ships fleet in map 1-5 just fine after testing.

Webm: https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/Orel.webm

Config: https://dl.dropboxusercontent.com/u/73564551/Games/KanColle/config.ini

mrmin123 commented 8 years ago

@Aftersky Honestly, I think a different approach to how kancolle-auto selects formations is the best bet here. Now that I have global_regions working I'm thinking of defining a very restricted global region for each formation, and then bumping down the required match % for the actual formation images. Previously this had issues with line abreast and line ahead because they looked so similar to Sikuli, but with global regions defined it should only search in the relevant place, thus eliminating the danger of clicking the wrong formation. I'm going to make a separate ticket for this for easy reference.