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

Intermittent crashes due to index error #264

Closed waicool20 closed 7 years ago

waicool20 commented 7 years ago

Environment details

Issue

Intermittent crashes due to index error in script, I'm not exactly a python person so I couldn't fix it myself.

Console log

Full log and used config here: http://pastebin.com/PZSdk2Vd Just use this regex to find errors:

(([error] --- Traceback --- error source first)(.*\n)+?([error] --- Traceback --- end --------------))

Main error

6 of these:

[error] script [ /home/waicool20/bin/kancolle-auto/kancolle_auto.sikuli ] stopped with error in line 524 [error] IndexError ( index out of range: 0 ) [error] --- Traceback --- error source first line: module ( function ) statement 648: combat ( next_sortie_time_set ) self.next_sortie_time = self.repair_timers[0] 462: combat ( go_repair ) self.next_sortie_time_set() 242: main ( sortie_action ) combat_item.go_repair() 462: main ( kancolle_auto_wrapper ) sortie_action() 524: main ( ) kancolle_auto_wrapper() [error] --- Traceback --- end --------------

1 of this:

[log] TYPE "#ESC." [2017-01-23 19:11:28] Non-catbomb script crash, or catbomb script crash w/ unsupported Viewer! FindFailed: combat_area_3.png: (50x32) seen at (363, 507) with 1.00 in S(0)[0,0 1920x1080] E:Y, T:3.0 Line 2718, in file Region.java [error] script [ /home/waicool20/bin/kancolle-auto/kancolle_auto.sikuli ] stopped with error in line 526 [error] FindFailed ( combat_area_3.png: (50x32) seen at (363, 507) with 1.00 in S(0)[0,0 1920x1080] E:Y, T:3.0 ) [error] --- Traceback --- error source first line: module ( function ) statement 548: util ( pattern_generator ) m = match(r'M[\d+\,\d+ (\d+)x(\d+)]', str(find(pic))) 523: util ( wait_and_click ) kc_region.wait(pattern_generator(kc_region, pic, expand), time) 129: combat ( go_sortie ) wait_and_click(self.kc_region, self.area_pict) 227: main ( sortie_action ) combat_results = combat_item.go_sortie() 462: main ( kancolle_auto_wrapper ) sortie_action() 524: main ( ) kancolle_auto_wrapper() [error] --- Traceback --- end --------------

mrmin123 commented 7 years ago

@waicool20 the second error (combat_area_3.png FindFailed) can usually be attributed to a lag in the display (took more than 5 seconds for the server to respond) or a Sikuli match failure. If it's the former, I guess I could raise the default wait time to something like 10 seconds (I'll actually go ahead and do that), but if it's the latter, there isn't much I can do.

Oops, hit enter before I was done typing: The first error is a bit weird... that bit of code only triggers if the repair ports are all full. If it is, it looks to look at the sorted repair_timers list and gets the first (shortest) timer value to figure out when to check back. Oddly enough, the repair_timers list is empty, which is why we're getting the error, but also implies that nothing got repaired. I'd need more information on this, like whether or not the ports were actually full, and if they were, if they were filled manually...

waicool20 commented 7 years ago

Probably not filled manually, since I actually left KAGA running for a while and restarting Kancolle Auto as needed to "farm" these tracebacks.

Port was probably not full, the script usually rotates between 2/3 subs, and one of them is usually done repairing by the time the current one is damaged.

Can't you just check if the size or repair_timers is larger than 1 before running that code?

mrmin123 commented 7 years ago

I'd rather nail down the source of the behavior than add a workaround to make the script not crash when it should, especially when I'm not certain of the cause of the error since depending on the cause it might have unintended consequences further down the line. Doing a bit more digging right now.

mrmin123 commented 7 years ago

Upon further analysis of the logs I've concluded that the crashes are due to all repair ports being full, and the code for recognizing and interpreting the timers for pre-existing repairs not working properly. In the below log snippets you can see that the 'repair should be done' times are after the time of crash:

[2017-01-23 18:46:29] Available docks: 2; repair queue: 1
...
[2017-01-23 18:46:37] Got valid timer (00:17:35)!
[2017-01-23 18:46:37] Repair should be done at 2017-01-23 19:02:37
...
...
...
[2017-01-23 18:56:40] Available docks: 1; repair queue: 1
...
[2017-01-23 18:56:48] Got valid timer (00:15:22)!
[2017-01-23 18:56:48] Repair should be done at 2017-01-23 19:10:48
...
...
...
[2017-01-23 19:02:39] Navigating to repair screen with 0 sidestep(s)!
[log] CLICK on L(187,417)@S(0)[0,0 1920x1080] (521 msec)
[error] script [ /home/waicool20/bin/kancolle-auto/kancolle_auto.sikuli ] stopped with error in line 524
[error] IndexError ( index out of range: 0 )
[2017-01-23 21:02:00] Available docks: 2; repair queue: 1
...
[2017-01-23 21:02:07] Got valid timer (00:25:00)!
[2017-01-23 21:02:07] Repair should be done at 2017-01-23 21:26:07
...
...
...
[2017-01-23 21:14:50] Available docks: 1; repair queue: 1
...
[2017-01-23 21:14:58] Got valid timer (00:15:40)!
[2017-01-23 21:14:58] Repair should be done at 2017-01-23 21:28:58
...
...
...
[2017-01-23 21:23:13] Navigating to repair screen with 0 sidestep(s)!
[log] CLICK on L(226,471)@S(0)[0,0 1920x1080] (521 msec)
[error] script [ /home/waicool20/bin/kancolle-auto/kancolle_auto.sikuli ] stopped with error in line 524
[error] IndexError ( index out of range: 0 )
[error] --- Traceback --- error source first
[2017-01-23 22:15:00] Available docks: 2; repair queue: 1
...
[2017-01-23 22:15:11] Got valid timer (00:19:15)!
[2017-01-23 22:15:11] Repair should be done at 2017-01-23 22:33:11
...
...
...
[2017-01-23 22:23:43] Available docks: 1; repair queue: 1
...
[2017-01-23 22:23:51] Got valid timer (00:11:20)!
[2017-01-23 22:23:51] Repair should be done at 2017-01-23 22:33:51
...
...
...
[2017-01-23 22:29:16] Navigating to repair screen with 0 sidestep(s)!
[log] CLICK on L(195,434)@S(0)[0,0 1920x1080] (522 msec)
[error] script [ /home/waicool20/bin/kancolle-auto/kancolle_auto.sikuli ] stopped with error in line 524
[error] IndexError ( index out of range: 0 )
waicool20 commented 7 years ago

It indeed always crashes whenever the repair slots are full, I tested it by starting the script with all my repair slots full and it would always crash after navigating to the repair screen. But this also means that the script is crashing whether or not the "Repair should be done at X" message are relevant