Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
veadex committed Feb 19, 2024
1 parent 8c43dbc commit 32f42ce
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 40 deletions.
2 changes: 1 addition & 1 deletion autowsgr/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.2.15"
__version__ = "0.2.2.16"
Binary file modified autowsgr/data/images/choose_ship_image/3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion autowsgr/data/plans/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ normal_fight_defaults: # 常规战斗的默认参数(包括活动)
battle_defaults: # 战役的默认参数
map: 1 # 简单1-5 困难6-10
repair_mode: 1 # 1:中破就修 2:只修大破;也可以用列表指定6个位置不同修理方案 [1, 1, 1, 1, 1, 1]

fleet_id: 3
node_defaults: #
# 演习特有的参数
fleet_id: 1 # 队伍编号,可以在自己的方案中设置,机器人和玩家独立
Expand Down
33 changes: 33 additions & 0 deletions autowsgr/data/plans/normal_fight/9-2ADGHM.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 功能:飞铝速刷胖次
# 带路条件:装母>=2
# 索敌条件:
# 推荐配置:赤城基阿特鞍山大凤G6G15 攻略参考https://bbs.nga.cn/read.php?tid=19809146
# 同时可以使用这个脚本在9-2倒油完成特建任务

# MapLevel
chapter: 9
map: 2
selected_nodes: [A, D, G, H, M]
repair_mode: 1 #1中破修,2大破修
# NodeLevel
node_defaults:
enemy_rules:
- [SAP != 1, detour]
formation: 2 # 正常情况阵型选择, 1-5
# 夜战选择阶段
night: False # 是否夜战
SL_when_detour_fails: True # 是否迂回失败后退出
# 前进选择阶段
proceed: True # 结束后是否继续
proceed_stop: [2, 2, 2, 2, 2, 2] # 根据我方血量状态选择是否继续前进,一旦对应破损程度达到或超过该值则返回

node_args:
M:
enemy_rules:
- [SAP != 1, detour]
formation: 2 # 正常情况阵型选择, 1-5
# 夜战选择阶段
night: False # 是否夜战
SL_when_detour_fails: True # 是否迂回失败后退出
# 前进选择阶段
proceed: False # 结束后是否继续
15 changes: 0 additions & 15 deletions autowsgr/data/plans/normal_fight/9-3.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions autowsgr/data/plans/normal_fight/9-3AD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 功能:9-3航空点二连炸
# 带路:带一艘航速低于27节的船
# 配队:推荐赤城+大凤或者大凤+祥凤,0铝阵容,四个练级位,打之前先压制

# MapLevel
chapter: 9
map: 3
selected_nodes: [A, D]

# NodeLevel
node_args:
A:
formation: 4
proceed: True
D:
formation: 4
proceed: False
22 changes: 10 additions & 12 deletions autowsgr/ocr/digit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

import numpy as np

from AutoWSGR.controller.run_timer import Timer
from autowsgr.controller.run_timer import Timer
from autowsgr.ocr.paddle__ocr import paddle_ocr
from autowsgr.ocr.ship_name import recognize_number

# import pytesseract
#from AutoWSGR.ocr.ship_name import recognize_number
from AutoWSGR.utils.api_image import crop_image
from AutoWSGR.utils.io import yaml_to_dict
from AutoWSGR.ocr.ship_name import recognize_number

from AutoWSGR.ocr.paddle__ocr import paddle_ocr


# from AutoWSGR.ocr.ship_name import recognize_number
from autowsgr.utils.api_image import crop_image
from autowsgr.utils.io import yaml_to_dict

POS = yaml_to_dict(os.path.join(os.path.dirname(__file__), "relative_location.yaml"))

Expand Down Expand Up @@ -52,7 +49,7 @@ def get_resources(timer: Timer):
image = timer.screen
ret = {}
for key in POS["main_page"]["resources"]:
image_crop = crop_image(image, *POS["main_page"]["resources"][key],resolution=timer.config.resolution)
image_crop = crop_image(image, *POS["main_page"]["resources"][key], resolution=timer.config.resolution)
raw_str = paddle_ocr(image_crop)
try:
raw_str = raw_str[0][1][0]
Expand Down Expand Up @@ -82,7 +79,7 @@ def get_loot_and_ship(timer: Timer):
image = timer.screen
ret = {}
for key in POS["map_page"]:
image_crop = crop_image(image, *POS['map_page'][key],resolution= timer.config.resolution)
image_crop = crop_image(image, *POS["map_page"][key], resolution=timer.config.resolution)
raw_str = paddle_ocr(image_crop)
try:
raw_str = raw_str[0][1][0]
Expand Down Expand Up @@ -110,5 +107,6 @@ def get_loot_and_ship(timer: Timer):
timer.logger.info(f"已掉落舰船:{timer.got_ship_num}")
return ret


def get_flop_ship(timer: Timer):
pass
pass
26 changes: 15 additions & 11 deletions autowsgr/ocr/paddle__ocr.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
from paddleocr import PaddleOCR, draw_ocr
from AutoWSGR.utils.api_image import crop_image

from autowsgr.utils.api_image import crop_image

en_paddle_ocr = None
cn_paddle_ocr = None


def load_en_ocr():
global en_paddle_ocr
en_paddle_ocr = PaddleOCR(use_angle_cls=True, lang="en",show_log = False) # need to run only once to download and load model into memory
en_paddle_ocr = PaddleOCR(
use_angle_cls=True, lang="en", show_log=False
) # need to run only once to download and load model into memory


def load_ch_ocr():
global cn_paddle_ocr
cn_paddle_ocr = PaddleOCR(use_angle_cls=True, lang="ch",show_log = False) # need to run only once to download and load model into memory
cn_paddle_ocr = PaddleOCR(
use_angle_cls=True, lang="ch", show_log=False
) # need to run only once to download and load model into memory

def paddle_ocr(image, language = "en"):

def paddle_ocr(image, language="en"):
if language == "ch":
if cn_paddle_ocr == None:
load_ch_ocr()
result = cn_paddle_ocr.ocr(image , cls=True)
elif language == "en" :
result = cn_paddle_ocr.ocr(image, cls=True)
elif language == "en":
if en_paddle_ocr == None:
load_en_ocr()
result = en_paddle_ocr.ocr(image,cls=True)
#print(f"原始数据为: {result}")
result = en_paddle_ocr.ocr(image, cls=True)
# print(f"原始数据为: {result}")
try:
return result[0]
except:
result = None
return result
return result


"""if __name__ == "__main__":
image="4.PNG"
#image_crop = crop_image(image, resolution=timer.config.resolution)
result = paddle_ocr(image,language = "ch")
print(result)"""


0 comments on commit 32f42ce

Please sign in to comment.