Fix: Sort routes in position interger not string

This commit is contained in:
LmeSzinc 2023-10-02 03:04:08 +08:00
parent 0e78cbb4a6
commit 2854232778
5 changed files with 122 additions and 127 deletions

View File

@ -99,6 +99,18 @@ def model_to_json(model, file):
f.write(content)
regex_posi = re.compile(r'_?X(\d+)Y(\d+)')
def get_position_from_name(name):
res = regex_posi.search(name)
if res:
position = int(res.group(1)), int(res.group(2))
else:
position = (0, 0)
return position
class RouteDetect:
GEN_END = '===== End of generated waypoints ====='
@ -116,7 +128,6 @@ class RouteDetect:
return self.detector.all_minimap[route.plane_floor]
def iter_image(self) -> Iterator[RogueWaypointModel]:
regex_posi = re.compile(r'_?X(\d+)Y(\d+)')
for domain_folder in iter_folder(self.folder, is_dir=True):
domain = os.path.basename(domain_folder)
for route_folder in iter_folder(domain_folder, is_dir=True):
@ -128,11 +139,7 @@ class RouteDetect:
parts = route.split('_', maxsplit=3)
if len(parts) == 4:
world, plane, floor, position = parts
res = regex_posi.search(position)
if res:
position = int(res.group(1)), int(res.group(2))
else:
position = (0, 0)
position = get_position_from_name(position)
elif len(parts) == 3:
world, plane, floor = parts
position = (0, 0)
@ -144,9 +151,9 @@ class RouteDetect:
continue
file = f'{self.folder}/{domain}/{route}/route/{waypoint}.png'
res = regex_posi.search(waypoint)
if res:
position = int(res.group(1)), int(res.group(2))
file_position = get_position_from_name(waypoint)
if file_position != (0, 0):
position = file_position
# waypoint = regex_posi.sub('', waypoint)
elif waypoint != 'spawn':
position = (0, 0)
@ -168,7 +175,6 @@ class RouteDetect:
pass
def predict(self):
regex_posi = re.compile(r'_?X(\d+)Y(\d+)')
for waypoint in tqdm(self.waypoints.grids):
waypoint: RogueWaypointModel = waypoint
minimap = self.get_minimap(waypoint)
@ -383,7 +389,7 @@ class RouteDetect:
code = code.removesuffix('\n def').removeprefix('\n')
routes.append((route, code))
sorted_routes = sorted(routes, key=lambda x: x[0])
sorted_routes = sorted(routes, key=lambda x: get_position_from_name(x[0]))
routes = [route[1] for route in routes]
sorted_routes = [route[1] for route in sorted_routes]
new = ''

View File

@ -5,24 +5,6 @@ from tasks.rogue.route.base import RouteBase
class Route(RouteBase):
def Herta_SupplyZone_F2_X215Y112(self):
"""
| Waypoint | Position | Direction | Rotation |
| ------------- | ------------------------- | --------- | -------- |
| spawn | Waypoint((215.6, 112.7)), | 96.7 | 91 |
| item_X227Y105 | Waypoint((227.4, 105.0)), | 67.2 | 61 |
| enemy | Waypoint((264.4, 114.1)), | 101.1 | 98 |
| exit_X227Y105 | Waypoint((266.7, 113.7)), | 60.8 | 91 |
"""
self.map_init(plane=Herta_SupplyZone, floor="F2", position=(215.6, 112.7))
self.register_domain_exit(Waypoint((266.7, 113.7)), end_rotation=91)
item_X227Y105 = Waypoint((227.4, 105.0))
enemy = Waypoint((264.4, 114.1))
# ===== End of generated waypoints =====
self.clear_item(item_X227Y105)
self.clear_enemy(enemy)
def Herta_SupplyZone_F2_X45Y369(self):
"""
| Waypoint | Position | Direction | Rotation |
@ -66,3 +48,21 @@ class Route(RouteBase):
self.clear_enemy(
enemy3_X114Y234.straight_run(),
)
def Herta_SupplyZone_F2_X215Y112(self):
"""
| Waypoint | Position | Direction | Rotation |
| ------------- | ------------------------- | --------- | -------- |
| spawn | Waypoint((215.6, 112.7)), | 96.7 | 91 |
| item_X227Y105 | Waypoint((227.4, 105.0)), | 67.2 | 61 |
| enemy | Waypoint((264.4, 114.1)), | 101.1 | 98 |
| exit_X227Y105 | Waypoint((266.7, 113.7)), | 60.8 | 91 |
"""
self.map_init(plane=Herta_SupplyZone, floor="F2", position=(215.6, 112.7))
self.register_domain_exit(Waypoint((266.7, 113.7)), end_rotation=91)
item_X227Y105 = Waypoint((227.4, 105.0))
enemy = Waypoint((264.4, 114.1))
# ===== End of generated waypoints =====
self.clear_item(item_X227Y105)
self.clear_enemy(enemy)

View File

@ -5,6 +5,24 @@ from tasks.rogue.route.base import RouteBase
class Route(RouteBase):
def Jarilo_GreatMine_F1_X84Y378(self):
"""
| Waypoint | Position | Direction | Rotation |
| -------- | ------------------------ | --------- | -------- |
| spawn | Waypoint((84.4, 378.7)), | 334.8 | 331 |
| item | Waypoint((60.2, 358.5)), | 319.8 | 308 |
| enemy | Waypoint((56.2, 330.8)), | 340.7 | 149 |
| exit | Waypoint((57.4, 329.5)), | 22.8 | 334 |
"""
self.map_init(plane=Jarilo_GreatMine, floor="F1", position=(84.4, 378.7))
self.register_domain_exit(Waypoint((57.4, 329.5)), end_rotation=334)
item = Waypoint((60.2, 358.5))
enemy = Waypoint((56.2, 330.8))
# ===== End of generated waypoints =====
self.clear_item(item)
self.clear_enemy(enemy)
def Jarilo_GreatMine_F1_X133Y465(self):
"""
| Waypoint | Position | Direction | Rotation |
@ -81,7 +99,7 @@ class Route(RouteBase):
"""
| Waypoint | Position | Direction | Rotation |
| -------- | ------------------------- | --------- | -------- |
| spawn | Waypoint((485.4, 450.4)), | 177.8 | 172 |
| spawn | Waypoint((485.5, 450.4)), | 177.8 | 172 |
| item1 | Waypoint((478.8, 484.8)), | 199.8 | 193 |
| item2 | Waypoint((488.4, 522.0)), | 175.8 | 170 |
| enemy3 | Waypoint((465.3, 531.1)), | 92.8 | 232 |
@ -91,7 +109,7 @@ class Route(RouteBase):
| node4 | Waypoint((480.3, 575.6)), | 105.5 | 101 |
| exit | Waypoint((549.0, 515.6)), | 112.7 | 15 |
"""
self.map_init(plane=Jarilo_GreatMine, floor="F1", position=(485.4, 450.4))
self.map_init(plane=Jarilo_GreatMine, floor="F1", position=(485.5, 450.4))
self.register_domain_exit(Waypoint((549.0, 515.6)), end_rotation=15)
item1 = Waypoint((478.8, 484.8))
item2 = Waypoint((488.4, 522.0))
@ -157,21 +175,3 @@ class Route(RouteBase):
self.clear_enemy(
enemy3.straight_run(),
)
def Jarilo_GreatMine_F1_X84Y378(self):
"""
| Waypoint | Position | Direction | Rotation |
| -------- | ------------------------ | --------- | -------- |
| spawn | Waypoint((84.4, 378.7)), | 334.8 | 331 |
| item | Waypoint((60.2, 358.5)), | 319.8 | 308 |
| enemy | Waypoint((56.2, 330.8)), | 340.7 | 149 |
| exit | Waypoint((57.4, 329.5)), | 22.8 | 334 |
"""
self.map_init(plane=Jarilo_GreatMine, floor="F1", position=(84.4, 378.7))
self.register_domain_exit(Waypoint((57.4, 329.5)), end_rotation=334)
item = Waypoint((60.2, 358.5))
enemy = Waypoint((56.2, 330.8))
# ===== End of generated waypoints =====
self.clear_item(item)
self.clear_enemy(enemy)

View File

@ -5,6 +5,40 @@ from tasks.rogue.route.base import RouteBase
class Route(RouteBase):
def Luofu_Cloudford_F1_X59Y405(self):
"""
| Waypoint | Position | Direction | Rotation |
| ------------- | ------------------------- | --------- | -------- |
| spawn | Waypoint((59.3, 405.6)), | 96.7 | 91 |
| item1 | Waypoint((97.2, 393.0)), | 87.7 | 84 |
| enemy1 | Waypoint((126.3, 402.5)), | 96.8 | 101 |
| enemy2top | Waypoint((214.6, 432.8)), | 94.1 | 87 |
| enemy2bottom | Waypoint((215.4, 481.0)), | 191.8 | 174 |
| enemy3 | Waypoint((288.0, 452.2)), | 87.7 | 260 |
| exit_X288Y454 | Waypoint((288.5, 454.5)), | 5.7 | 91 |
"""
self.map_init(plane=Luofu_Cloudford, floor="F1", position=(59.3, 405.6))
self.register_domain_exit(Waypoint((288.5, 454.5)), end_rotation=91)
item1 = Waypoint((97.2, 393.0))
enemy1 = Waypoint((126.3, 402.5))
enemy2top = Waypoint((214.6, 432.8))
enemy2bottom = Waypoint((215.4, 481.0))
enemy3 = Waypoint((288.0, 452.2))
# ===== End of generated waypoints =====
# 1
self.clear_item(item1)
self.clear_enemy(enemy1)
# 2 moving enemy
self.clear_enemy(
enemy2top,
enemy2bottom.straight_run(),
)
# 3
self.clear_enemy(
enemy3.straight_run(),
)
def Luofu_Cloudford_F1_X241Y947(self):
"""
| Waypoint | Position | Direction | Rotation |
@ -77,37 +111,3 @@ class Route(RouteBase):
# 2
self.clear_item(item2)
self.clear_enemy(enemy2)
def Luofu_Cloudford_F1_X59Y405(self):
"""
| Waypoint | Position | Direction | Rotation |
| ------------- | ------------------------- | --------- | -------- |
| spawn | Waypoint((59.3, 405.6)), | 96.7 | 91 |
| item1 | Waypoint((97.2, 393.0)), | 87.7 | 84 |
| enemy1 | Waypoint((126.3, 402.5)), | 96.8 | 101 |
| enemy2top | Waypoint((214.6, 432.8)), | 94.1 | 87 |
| enemy2bottom | Waypoint((215.4, 481.0)), | 191.8 | 174 |
| enemy3 | Waypoint((288.0, 452.2)), | 87.7 | 260 |
| exit_X288Y454 | Waypoint((288.5, 454.5)), | 5.7 | 91 |
"""
self.map_init(plane=Luofu_Cloudford, floor="F1", position=(59.3, 405.6))
self.register_domain_exit(Waypoint((288.5, 454.5)), end_rotation=91)
item1 = Waypoint((97.2, 393.0))
enemy1 = Waypoint((126.3, 402.5))
enemy2top = Waypoint((214.6, 432.8))
enemy2bottom = Waypoint((215.4, 481.0))
enemy3 = Waypoint((288.0, 452.2))
# ===== End of generated waypoints =====
# 1
self.clear_item(item1)
self.clear_enemy(enemy1)
# 2 moving enemy
self.clear_enemy(
enemy2top,
enemy2bottom.straight_run(),
)
# 3
self.clear_enemy(
enemy3.straight_run(),
)

View File

@ -43,17 +43,6 @@
],
"domain": "Combat"
},
{
"name": "Combat_Herta_SupplyZone_F2_X215Y112",
"route": "route.rogue.Combat.Herta_SupplyZone_F2:Herta_SupplyZone_F2_X215Y112",
"plane": "Herta_SupplyZone",
"floor": "F2",
"position": [
215.6,
112.7
],
"domain": "Combat"
},
{
"name": "Combat_Herta_SupplyZone_F2_X45Y369",
"route": "route.rogue.Combat.Herta_SupplyZone_F2:Herta_SupplyZone_F2_X45Y369",
@ -65,6 +54,17 @@
],
"domain": "Combat"
},
{
"name": "Combat_Herta_SupplyZone_F2_X215Y112",
"route": "route.rogue.Combat.Herta_SupplyZone_F2:Herta_SupplyZone_F2_X215Y112",
"plane": "Herta_SupplyZone",
"floor": "F2",
"position": [
215.6,
112.7
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_BackwaterPass_F1_X475Y49",
"route": "route.rogue.Combat.Jarilo_BackwaterPass_F1:Jarilo_BackwaterPass_F1_X475Y49",
@ -120,6 +120,17 @@
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_GreatMine_F1_X84Y378",
"route": "route.rogue.Combat.Jarilo_GreatMine_F1:Jarilo_GreatMine_F1_X84Y378",
"plane": "Jarilo_GreatMine",
"floor": "F1",
"position": [
84.4,
378.7
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_GreatMine_F1_X133Y465",
"route": "route.rogue.Combat.Jarilo_GreatMine_F1:Jarilo_GreatMine_F1_X133Y465",
@ -153,17 +164,6 @@
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_GreatMine_F1_X485Y452",
"route": "route.rogue.Combat.Jarilo_GreatMine_F1:Jarilo_GreatMine_F1_X485Y452",
"plane": "Jarilo_GreatMine",
"floor": "F1",
"position": [
485.4,
450.4
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_GreatMine_F1_X485Y450",
"route": "route.rogue.Combat.Jarilo_GreatMine_F1:Jarilo_GreatMine_F1_X485Y450",
@ -186,17 +186,6 @@
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_GreatMine_F1_X84Y378",
"route": "route.rogue.Combat.Jarilo_GreatMine_F1:Jarilo_GreatMine_F1_X84Y378",
"plane": "Jarilo_GreatMine",
"floor": "F1",
"position": [
84.4,
378.7
],
"domain": "Combat"
},
{
"name": "Combat_Jarilo_RivetTown_F1_X181Y439",
"route": "route.rogue.Combat.Jarilo_RivetTown_F1:Jarilo_RivetTown_F1_X181Y439",
@ -296,6 +285,17 @@
],
"domain": "Combat"
},
{
"name": "Combat_Luofu_Cloudford_F1_X59Y405",
"route": "route.rogue.Combat.Luofu_Cloudford_F1:Luofu_Cloudford_F1_X59Y405",
"plane": "Luofu_Cloudford",
"floor": "F1",
"position": [
59.3,
405.6
],
"domain": "Combat"
},
{
"name": "Combat_Luofu_Cloudford_F1_X241Y947",
"route": "route.rogue.Combat.Luofu_Cloudford_F1:Luofu_Cloudford_F1_X241Y947",
@ -329,17 +329,6 @@
],
"domain": "Combat"
},
{
"name": "Combat_Luofu_Cloudford_F1_X59Y405",
"route": "route.rogue.Combat.Luofu_Cloudford_F1:Luofu_Cloudford_F1_X59Y405",
"plane": "Luofu_Cloudford",
"floor": "F1",
"position": [
59.3,
405.6
],
"domain": "Combat"
},
{
"name": "Elite_Herta_StorageZone_F1_X477Y233",
"route": "route.rogue.Elite.Herta_StorageZone_F1:Herta_StorageZone_F1_X477Y233",