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

Error after a reboot due catbomb #177

Closed Nuts123 closed 8 years ago

Nuts123 commented 8 years ago

Environment details

default

Console log (if applicable)

[log] App.focus Google Chrome(0) #0
[error] script stopped with error in line 504
[error] AttributeError ( 'NoneType' object has no attribute 'x' )
Exception in thread "main" java.lang.IllegalStateException: No match found
        at java.util.regex.Matcher.group(Matcher.java:536)
        at org.sikuli.scriptrunner.JythonScriptRunner.findErrorSourceWalkTrace(J
ythonScriptRunner.java:326)
        at org.sikuli.scriptrunner.JythonScriptRunner.findErrorSource(JythonScri
ptRunner.java:290)
        at org.sikuli.scriptrunner.JythonScriptRunner.runPython(JythonScriptRunn
er.java:200)
        at org.sikuli.scriptrunner.JythonScriptRunner.runScript(JythonScriptRunn
er.java:162)
        at org.sikuli.basics.SikuliScript.main(SikuliScript.java:181)

Relevant config snippet (if applicable)

Program: Google Chrome
RecoveryMethod: KC3
SleepCycle = 4
Paranoia = 1
mrmin123 commented 8 years ago

So does it actually refresh the page? At the time of crash, is the game page still loading in the browser like in your screenshot?

Nuts123 commented 8 years ago

there is a sequence: 1) catbomb 2) bot refresh the page 3) bot crash in moment as in the screenshoot 4) bot terminated but game screen loaded

may need to add (config.ini) a delay after the update page?

Nuts123 commented 8 years ago

by the way, there one other problem: catbombs every 5 min after a day of use

mrmin123 commented 8 years ago

@Nuts123 Right now the catbomb recovery just waits 60 seconds before looking for the game start button. I could add a looped check for the button. Not sure how it got past that and crashed at what looks like in the focus_window function, however.

As for catbombs after every 5 minutes, that's more of an issue with how you might have configured/are using kancolle-auto. If it's set to be aggressive/very active then you'll probably trigger their bot detection. If it's configured to be relatively passive, you should be ok.

Nuts123 commented 8 years ago

Right now the catbomb recovery just waits 60 seconds before looking for the game start button.

Sorry, but judging from the error he is looking for a window immediately after the 'F5 enter TAB enter'

mrmin123 commented 8 years ago

Since you're encountering the cat a lot right now maybe you can test the code. Replace line 426 (wait_and_click(kc_window, Pattern('game_start.png').exact(), WAITLONG)) with:

        while not kc_window.exists(Pattern('game_start.png').similar(0.999)):
            sleep(2)
        check_and_click(kc_window, 'game_start.png')
Nuts123 commented 8 years ago

O, it's work! But new error

default

(i use log for test)

This error occurs after the "game start"

But this is not a problem, since on the VBS was written a simple script that restarts the bot on any error

Do: CreateObject("WScript.Shell").Run """C:\Users\maks\Desktop\Sikuli\start.bat""", , True: Loop

start.bat java -jar sikuli-script.jar -r kancolle-auto-master/kancolle_auto.sikuli

offer users this method to improve the reliability of the bot.

mrmin123 commented 8 years ago

I think that that can be rectified by adding a call to init() at the end of the catbomb recovery function, so I'm going to add that in, but thanks for providing the vbs workaround.

Nuts123 commented 8 years ago

Sorry that I write here. I found another bug. Sometimes, the bot gets a catbomb when you send an expedition, but writes to the console that the expedition was sent, but the expedition was not sent.

mrmin123 commented 8 years ago

@Nuts123 Wait, so kancolle-auto presses the expedition start button, but upon doing so, the game catbombs, and if you reload the game, the expedition was never sent?

I could account for this, but it really does seem like you're encountering a lot more catbombs than the average user of this bot is... perhaps tweak your settings so it's less likely to trigger bot detection, or come back to the bot after a day or two of taking a break from it?

Nuts123 commented 8 years ago

Wait, so kancolle-auto presses the expedition start button, but upon doing so, the game catbombs, and if you reload the game, the expedition was never sent?

Yes, sometimes

I could account for this, but it really does seem like you're encountering a lot more catbombs than the average user of this bot is... perhaps tweak your settings so it's less likely to trigger bot detection, or come back to the bot after a day or two of taking a break from it?

I tried to not enter the game 1.5 days, but it did not help...

mrmin123 commented 8 years ago

@Nuts123 I'm a bit hesitant to add the post-expedition catbomb recovery because I don't know how many other people are plagued by that particular issue, but I'm going to test it for a bit to see. If you want the code, it's this. Replace expedition_action() in kancolle_auto.py with this:

def expedition_action(fleet_id):
    global kc_window, fleet_needs_resupply, expedition_item, settings
    for expedition in expedition_item.expedition_list:
        if fleet_id == 'all':
            pass
        else:
            if fleet_id != expedition.fleet_id:
                continue
        while expedition_item.run_expedition(expedition):
            fleet_needs_resupply[expedition.fleet_id - 1] = True
            check_and_click(global_regions['game'], 'menu_side_resupply.png')
            resupply()
            expedition_item.go_expedition()
        fleet_needs_resupply[expedition.fleet_id - 1] = False
        sleep(2)
        if kc_window.exists('catbomb.png') and settings['recovery_method'] != 'None':
            refresh_kancolle('Post-expedition crash')