AxelBjork / Rush-Royale-Bot

Python based bot for Rush Royale
MIT License
32 stars 21 forks source link

🐛 Random Crash after Battle #29

Closed Hona closed 2 years ago

Hona commented 2 years ago
Exception in thread Thread-7:
Traceback (most recent call last):
  File "C:\Users\Lukem\AppData\Local\Programs\Python\Python39\lib\threading.py", line 980, in _bootstrap_inner
    self.run()
  File "C:\Users\Lukem\AppData\Local\Programs\Python\Python39\lib\threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_handler.py", line 127, in bot_loop
    grid_df,bot.unit_series,bot.merge_series,bot.df_groups,bot.info = combat_loop(bot,grid_df, user_level, user_target)
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_handler.py", line 82, in combat_loop
    grid_df,unit_series,merge_series,df_groups,info = bot.try_merge(prev_grid=grid_df,merge_target=user_target)
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_core.py", line 235, in try_merge
    grid_df=bot_perception.grid_status(names,prev_grid=prev_grid)
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_perception.py", line 60, in grid_status
    unit_guess= match_unit(filename,ref_colors,ref_units) if rank !=0 else ['empty.png',0]
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_perception.py", line 43, in match_unit
    unit_colors = get_color(filename,crop=True)
  File "C:\Repositories\Rush-Royale-Bot\Src\bot_perception.py", line 36, in get_color
    index = np.where(counts == sorted_count[i])[0][0]
IndexError: index 2 is out of bounds for axis 0 with size 2
image
iOZ06 commented 2 years ago

I get this same error as well.

AxelBjork commented 2 years ago

Thanks for the bug report!

I saw this bug yesterday as well but only added the fix to branch I was working on.

It's merged into main now https://github.com/AxelBjork/Rush-Royale-Bot/pull/30

The issue was if an image only had a single pixel color.

Hona commented 2 years ago

Awesome work

Closed via #30