Skip to content

Commit

Permalink
#129 增加1.6新路线 空间站黑塔 - 禁闭舱段
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorReid committed Dec 27, 2023
1 parent efbd6ce commit c2f06d3
Show file tree
Hide file tree
Showing 49 changed files with 14,713 additions and 44 deletions.
4 changes: 4 additions & 0 deletions config/echo_of_war_sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ plan_list:
plan_times: 3
run_times: 0
- point_id: P03_XZLF_R09_LYJ_BSDSS
team_num: 1
plan_times: 3
run_times: 0
- point_id: P01_KJZHT_R05_JBCD_F1_ZXDJY
team_num: 1
plan_times: 3
run_times: 0
24 changes: 24 additions & 0 deletions config/world_patrol/P01_KJZHT/R05_JBCD_R01_YWZBJ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
author: ['DoctorReid']
planet: '空间站黑塔'
region: '禁闭舱段'
floor: 2
tp: '药物制备间'
route:
- op: 'move'
data: [472, 748]
- op: 'move'
data: [433, 794]
- op: 'move'
data: [401, 770]
- op: 'move'
data: [428, 725]
- op: 'move'
data: [411, 711]
- op: 'move'
data: [338, 600]
- op: 'move'
data: [324, 485]
- op: 'patrol'
- op: 'move'
data: [380, 387]
- op: 'patrol'
28 changes: 28 additions & 0 deletions config/world_patrol/P01_KJZHT/R05_JBCD_R02_WC.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
author: ['DoctorReid']
planet: '空间站黑塔'
region: '禁闭舱段'
floor: 2
tp: '温床'
route:
- op: 'move'
data: [754, 350]
- op: 'move'
data: [772, 370]
- op: 'move'
data: [797, 409]
- op: 'move'
data: [816, 453]
- op: 'move'
data: [829, 523]
- op: 'move'
data: [824, 580]
- op: 'move'
data: [810, 629]
- op: 'patrol'
- op: 'move'
data: [773, 688]
- op: 'move'
data: [722, 735]
- op: 'move'
data: [683, 759]
- op: 'patrol'
Binary file modified data/locales/en/LC_MESSAGES/ocr.mo
Binary file not shown.
19 changes: 19 additions & 0 deletions data/locales/ocr/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ msgstr "Storage"
msgid "支援舱段"
msgstr "Supply"

msgid "禁闭舱段"
msgstr "Seclusion"

msgid "行政区"
msgstr "Administrative District"

Expand Down Expand Up @@ -246,6 +249,22 @@ msgstr "Destruction's Beginning"
msgid "配控装置"
msgstr "Control Device"

# Special Point - Herta Space Station - Seclusion Zone
msgid "温床"
msgstr "Breeding Ground"

msgid "集散中心"
msgstr "Distribution Center"

msgid "培养皿"
msgstr "Incubator"

msgid "药物制备间"
msgstr "Pharmaceutical Room"

msgid "蛀星的旧靥历战回响"
msgstr "Borehole Planet's Old Crater"

# Special Point - Jarilo-VI - Administrative District
msgid "黄金歌剧院"
msgstr "Golden Theater"
Expand Down
4,131 changes: 4,131 additions & 0 deletions images/map/P01_KJZHT/R05_JBCD_F1/features.xml

Large diffs are not rendered by default.

Binary file added images/map/P01_KJZHT/R05_JBCD_F1/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F1/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F1/origin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F1/raw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6,000 changes: 6,000 additions & 0 deletions images/map/P01_KJZHT/R05_JBCD_F2/features.xml

Large diffs are not rendered by default.

Binary file added images/map/P01_KJZHT/R05_JBCD_F2/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F2/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F2/origin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F2/raw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,892 changes: 3,892 additions & 0 deletions images/map/P01_KJZHT/R05_JBCD_F3/features.xml

Large diffs are not rendered by default.

Binary file added images/map/P01_KJZHT/R05_JBCD_F3/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F3/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F3/origin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/map/P01_KJZHT/R05_JBCD_F3/raw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
281 changes: 281 additions & 0 deletions images/template/mm_boss_04/features.xml

Large diffs are not rendered by default.

Binary file added images/template/mm_boss_04/gray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/template/mm_boss_04/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/template/mm_boss_04/origin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/template/mm_boss_04/raw.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 src/gui/one_stop_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def _after_stop(self):
self.sr_ctx.controller.close_game()

def _on_after_done_changed(self, e):
if not self.after_done_dropdown.value != 'shutdown':
if self.after_done_dropdown.value != 'shutdown':
log.info('已取消关机计划')
win_utils.cancel_shutdown_sys()

Expand Down
4 changes: 2 additions & 2 deletions src/sr/app/large_map_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _execute_one_round(self) -> bool:
:return:
"""
region_list = []
for l in [-1, 0, 1, 2]:
for l in [-1, 0, 1, 2, 3]:
region = region_with_another_floor(self.region, l)
if region is not None:
region_list.append(region)
Expand Down Expand Up @@ -155,6 +155,6 @@ def run_ops(self, ops) -> bool:
# 执行前先传送到别的地图
ctx = get_context()
ctx.init_all(renew=True)
r = map_const.P03_R10
r = map_const.P01_R05_L1
app = LargeMapRecorder(ctx, r)
app.execute()
1 change: 1 addition & 0 deletions src/sr/app/routine/echo_of_war.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
map_const.P01_R04_SP06,
map_const.P02_R06_SP05,
map_const.P03_R09_SP06,
map_const.P01_R05_SP05,
]


Expand Down
72 changes: 61 additions & 11 deletions src/sr/cal_pos.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import concurrent.futures
from concurrent.futures import Future
from functools import lru_cache
from typing import List
from typing import List, Optional

import cv2
import numpy as np
Expand Down Expand Up @@ -37,13 +37,11 @@ def cal_character_pos(im: ImageMatcher,
"""
log.debug("准备计算当前位置 大地图区域 %s", lm_rect)

r1, r2, r3, r4 = None, None, None, None
result: MatchResult = None
result: Optional[MatchResult] = None

# 匹配结果 是缩放后的 offset 和宽高
if mm_info.sp_result is not None and len(mm_info.sp_result) > 0: # 有特殊点的时候 使用特殊点倒推位置
r1 = cal_character_pos_by_sp_result(lm_info, mm_info, lm_rect=lm_rect, show=show)
result = r1
result = cal_character_pos_by_sp_result(lm_info, mm_info, lm_rect=lm_rect, show=show)
if result is not None and (result.template_scale > 1.3 or result.template_scale < 0.9): # 不应该有这样的缩放 放弃这个结果
result = None
# 倒推位置失败 说明大地图附近有多个相同类型的特殊点 这时候使用特征匹配也没用了
Expand All @@ -53,13 +51,14 @@ def cal_character_pos(im: ImageMatcher,
# result = r2

if result is None: # 使用模板匹配 用灰度图的
r4: MatchResult = cal_character_pos_by_original(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)
result = r4
result = cal_character_pos_by_gray(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)

# 上面灰度图中 道理掩码部分有些楼梯扣不出来 所以下面用两个都扣不出楼梯的掩码图来匹配
if result is None: # 使用模板匹配 用道路掩码的
r3: MatchResult = cal_character_pos_by_road_mask(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)
result = r3
result = cal_character_pos_by_road_mask(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)

if result is None: # 使用模板匹配 用原图的
result = cal_character_pos_by_original(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)

# if result is None:
# result: MatchResult = cal_character_pos_by_merge_road_mask(im, lm_info, mm_info, lm_rect=lm_rect, running=running, show=show)
Expand Down Expand Up @@ -152,6 +151,58 @@ def cal_character_pos_by_feature_match(lm_info: LargeMapInfo, mm_info: MiniMapIn
return None


@record_performance
def cal_character_pos_by_gray(im: ImageMatcher,
lm_info: LargeMapInfo, mm_info: MiniMapInfo,
lm_rect: Rect = None,
running: bool = False,
show: bool = False) -> MatchResult:
"""
使用模板匹配 在大地图上匹配小地图的位置 会对小地图进行缩放尝试
使用小地图原图 - 实测灰度图更快
:param im: 图片匹配器
:param lm_info: 大地图信息
:param mm_info: 小地图信息
:param lm_rect: 圈定的大地图区域 传入后更准确
:param running: 任务是否在跑动
:param show: 是否显示调试结果
:return:
"""
source, lm_rect = cv2_utils.crop_image(lm_info.origin, lm_rect)
source = cv2.cvtColor(source, cv2.COLOR_BGR2GRAY)
# 使用道路掩码
radio_to_del = get_radio_to_del(im, mm_info.angle)
# mini_map.remove_radio(mm_info.origin, radio_to_del)
template = cv2.cvtColor(mm_info.origin, cv2.COLOR_BGR2GRAY)
rough_road_mask = mini_map.get_rough_road_mask(mm_info.origin,
sp_mask=mm_info.sp_mask,
arrow_mask=mm_info.arrow_mask,
angle=mm_info.angle,
# radio_to_del=radio_to_del,
another_floor=lm_info.region.another_floor)
template_mask = cv2.bitwise_and(mm_info.circle_mask, rough_road_mask)

target: MatchResult = template_match_with_scale_list_parallely(im, source, template, template_mask,
mini_map.get_mini_map_scale_list(running),
0.3)

if show:
scale = target.template_scale if target is not None else 1
template_usage = cv2_utils.scale_image(template, scale, copy=False)
template_mask_usage = cv2_utils.scale_image(template_mask, scale, copy=False)
cv2_utils.show_image(mm_info.origin, win_name='mini_map')
cv2_utils.show_image(source, win_name='template_match_source')
cv2_utils.show_image(cv2.bitwise_and(template_usage, template_usage, mask=template_mask_usage), win_name='template_match_template')
cv2_utils.show_image(template_mask, win_name='template_match_template_mask')

if target is not None:
offset_x = target.x + (lm_rect.x1 if lm_rect is not None else 0)
offset_y = target.y + (lm_rect.y1 if lm_rect is not None else 0)
return MatchResult(target.confidence, offset_x, offset_y, target.w, target.h, target.template_scale)
else:
return None


@record_performance
def cal_character_pos_by_original(im: ImageMatcher,
lm_info: LargeMapInfo, mm_info: MiniMapInfo,
Expand All @@ -170,10 +221,9 @@ def cal_character_pos_by_original(im: ImageMatcher,
:return:
"""
source, lm_rect = cv2_utils.crop_image(lm_info.origin, lm_rect)
source = cv2.cvtColor(source, cv2.COLOR_BGR2GRAY)
# 使用道路掩码
radio_to_del = get_radio_to_del(im, mm_info.angle)
template = cv2.cvtColor(mm_info.origin, cv2.COLOR_BGR2GRAY)
template = mini_map.remove_radio(mm_info.origin, radio_to_del)
rough_road_mask = mini_map.get_rough_road_mask(mm_info.origin,
sp_mask=mm_info.sp_mask,
arrow_mask=mm_info.arrow_mask,
Expand Down
13 changes: 12 additions & 1 deletion src/sr/const/map_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def display_name(self) -> str:
P01_R03_L2 = Region(3, "SRCD", "收容舱段", P01, 2)
P01_R04_L1 = Region(4, "ZYCD", "支援舱段", P01, 1)
P01_R04_L2 = Region(4, "ZYCD", "支援舱段", P01, 2)
P01_R05_L1 = Region(5, "JBCD", "禁闭舱段", P01, 1)
P01_R05_L2 = Region(5, "JBCD", "禁闭舱段", P01, 2)
P01_R05_L3 = Region(5, "JBCD", "禁闭舱段", P01, 3)

# 雅利洛
P02_R01_L1 = Region(1, "XZQ", "行政区", P02, floor=1)
Expand Down Expand Up @@ -165,7 +168,7 @@ def display_name(self) -> str:

# 这里的顺序需要保持和界面上的区域顺序一致
PLANET_2_REGION: Dict[str, List[Region]] = {
P01.np_id: [P01_R01, P01_R02, P01_R03_L1, P01_R03_L2, P01_R03_B1, P01_R04_L1, P01_R04_L2],
P01.np_id: [P01_R01, P01_R02, P01_R03_L1, P01_R03_L2, P01_R03_B1, P01_R04_L1, P01_R04_L2, P01_R05_L1, P01_R05_L2, P01_R05_L3],
P02.np_id: [P02_R01_L1, P02_R01_B1, P02_R02, P02_R03, P02_R04, P02_R05, P02_R06, P02_R07, P02_R08_L2, P02_R09, P02_R10,
P02_R11_L1, P02_R11_L2, P02_R12_L1, P02_R12_L2],
P03.np_id: [P03_R01, P03_R02_L1, P03_R02_L2, P03_R03_L1, P03_R03_L2, P03_R04, P03_R05, P03_R06_L1, P03_R06_L2,
Expand Down Expand Up @@ -245,6 +248,13 @@ def unique_id(self):
P01_R04_SP05 = TransportPoint('TKDT', '太空电梯', P01_R04_L2, 'mm_sp_02', (105, 345))
P01_R04_SP06 = TransportPoint('HMDKD', '毁灭的开端历战回响', P01_R04_L2, 'mm_boss_01', (1010, 286), (1015, 295))

# 空间站黑塔 - 禁闭舱段
P01_R05_SP01 = TransportPoint('WC', '温床', P01_R05_L2, 'mm_tp_03', (684, 306), (710, 309))
P01_R05_SP02 = TransportPoint('WC', '集散中心', P01_R05_L3, 'mm_tp_03', (642, 500), (609, 481))
P01_R05_SP03 = TransportPoint('PYM', '培养皿', P01_R05_L1, 'mm_tp_03', (669, 560), (677, 540))
P01_R05_SP04 = TransportPoint('YWZBJ', '药物制备间', P01_R05_L2, 'mm_tp_03', (541, 796), (530, 800))
P01_R05_SP05 = TransportPoint('ZXDJY', '蛀星的旧靥历战回响', P01_R05_L1, 'mm_boss_04', (571, 526), (582, 529))

# 雅利洛 - 行政区
P02_R01_SP01 = TransportPoint('HJGJY', '黄金歌剧院', P02_R01_L1, 'mm_tp_03', (603, 374), (619, 380))
P02_R01_SP02 = TransportPoint('ZYGC', '中央广场', P02_R01_L1, 'mm_tp_03', (487, 806), (501, 801))
Expand Down Expand Up @@ -489,6 +499,7 @@ def unique_id(self):
P01_R02.pr_id: [P01_R02_SP01, P01_R02_SP02, P01_R02_SP03, P01_R02_SP04],
P01_R03_L1.pr_id: [P01_R03_SP01, P01_R03_SP02, P01_R03_SP03, P01_R03_SP04, P01_R03_SP05, P01_R03_SP06, P01_R03_SP07],
P01_R04_L1.pr_id: [P01_R04_SP01, P01_R04_SP02, P01_R04_SP03, P01_R04_SP04, P01_R04_SP05, P01_R04_SP06],
P01_R05_L1.pr_id: [P01_R05_SP01, P01_R05_SP02, P01_R05_SP03, P01_R05_SP04, P01_R05_SP05],
P02_R01_L1.pr_id: [
P02_R01_SP01, P02_R01_SP02, P02_R01_SP03, P02_R01_SP04, P02_R01_SP05, P02_R01_SP06, P02_R01_SP07, P02_R01_SP08, P02_R01_SP09, P02_R01_SP10,
P02_R01_SP11, P02_R01_SP12, P02_R01_SP13, P02_R01_SP14, P02_R01_SP15, P02_R01_SP16, P02_R01_SP17, P02_R01_SP18, P02_R01_SP19],
Expand Down
4 changes: 2 additions & 2 deletions src/sr/const/traing_mission_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, id_cn: str, desc_cn: str, able: bool):

MISSION_DAILY_MISSION = DailyTrainingMission(id_cn='日常任务', desc_cn='完成1个日常任务', able=False)
MISSION_PATH = DailyTrainingMission(id_cn='侵蚀隧洞', desc_cn='完成1次侵蚀隧洞', able=False)
# MISSION_BUD1 = DailyTrainingMission(id_cn='拟造花萼金', desc_cn='完成1次拟造花萼金', able=False)
MISSION_BUD1 = DailyTrainingMission(id_cn='拟造花萼金', desc_cn='完成1次拟造花萼金', able=False)
MISSION_BUD2 = DailyTrainingMission(id_cn='拟造花萼赤', desc_cn='完成1次拟造花萼赤', able=False)
MISSION_FORGOTTEN_HALL = DailyTrainingMission(id_cn='忘却之庭', desc_cn='完成1次忘却之庭', able=False)
MISSION_SYNTHESIZE_CONSUMABLE = DailyTrainingMission(id_cn='合成消耗品', desc_cn='合成1次消耗品', able=True)
Expand All @@ -36,7 +36,7 @@ def __init__(self, id_cn: str, desc_cn: str, able: bool):
ALL_MISSION_LIST = [
MISSION_DAILY_MISSION,
MISSION_PATH,
# MISSION_BUD1,
MISSION_BUD1,
MISSION_BUD2,
MISSION_FORGOTTEN_HALL,
MISSION_USE_CONSUMABLE,
Expand Down
2 changes: 1 addition & 1 deletion src/sr/image/sceenshot/large_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def get_large_map_rect_by_pos(lm_shape, mm_shape, possible_pos: tuple = None) ->
x, y = int(possible_pos[0]), int(possible_pos[1])
# 还没有移动的话 通常是第一个点 这时候先默认移动1秒距离判断
r = 20 if len(possible_pos) < 3 or possible_pos[2] == 0 else int(possible_pos[2])
ur = r + 20 + mr + 5 # 潜在位置半径 = 移动距离 + 20(1秒移动距离) + 小地图半径 + 5(多留一些边缘匹配)
ur = r + mr + 5 # 潜在位置半径 = 移动距离 + 20(1秒移动距离) + 小地图半径 + 5(多留一些边缘匹配)
lm_offset_x = x - ur
lm_offset_y = y - ur
lm_offset_x2 = x + ur
Expand Down
16 changes: 11 additions & 5 deletions src/sr/image/sceenshot/mini_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ def get_rough_road_mask(mm: MatLike,
:param another_floor: 是否有其它楼层
:return:
"""
b, g, r = cv2.split(mm)
origin = remove_radio(mm, radio_to_del) if radio_to_del is not None else mm
# cv2_utils.show_image(origin, win_name='get_rough_road_mask_origin')

b, g, r = cv2.split(origin)
avg_b = np.mean(b)
avg_g = np.mean(g)
avg_r = np.mean(r)
Expand All @@ -526,13 +529,16 @@ def get_rough_road_mask(mm: MatLike,
ur = 55 if avg_r < 70 else 100
lower_color = np.array([45, 45, 45], dtype=np.uint8)
upper_color = np.array([ub, ug, ur], dtype=np.uint8)
road_mask_1 = cv2.inRange(mm, lower_color, upper_color)
road_mask_1 = cv2.inRange(origin, lower_color, upper_color)
# cv2_utils.show_image(road_mask_1, win_name='road_mask_1')

radio_mask = get_mini_map_radio_mask(mm, angle, another_floor)
# cv2_utils.show_image(radio_mask, win_name='radio_mask')
if radio_to_del is None:
radio_mask = get_mini_map_radio_mask(mm, angle, another_floor)
# cv2_utils.show_image(radio_mask, win_name='radio_mask')

center_mask = cv2.bitwise_or(arrow_mask, radio_mask)
center_mask = cv2.bitwise_or(arrow_mask, radio_mask)
else:
center_mask = arrow_mask
road_mask = cv2.bitwise_or(road_mask_1, center_mask)
road_mask = cv2.bitwise_or(road_mask, sp_mask)
# cv2_utils.show_image(road_mask, win_name='road_mask')
Expand Down
Loading

0 comments on commit c2f06d3

Please sign in to comment.