Quellcode durchsuchen

feat(Hyakkiyakou): Add a higher priority

ryland vor 2 Jahren
Ursprung
Commit
0aa8290374

+ 4 - 0
tasks/Hyakkiyakou/agent/agent.py

@@ -104,6 +104,10 @@ class Agent:
                     weight = -1.
                     weight = -1.
                     _cy += 100
                     _cy += 100
                 case _: continue
                 case _: continue
+            for priority in priorities:  # 我的代码在你之上
+                if priority == _class:
+                    weight = 1.7
+                    break
             if weight == 0.:
             if weight == 0.:
                 continue
                 continue
             z = embed_patch_in_canvas(canvas=z, patch=(mu * weight) * Agent.GAUSSIAN, position=(_cx, _cy))
             z = embed_patch_in_canvas(canvas=z, patch=(mu * weight) * Agent.GAUSSIAN, position=(_cx, _cy))

+ 2 - 2
tasks/Hyakkiyakou/agent/focus.py

@@ -72,7 +72,7 @@ velocity: {self._v}"""
         buff_omega, buff_cx, buff_cy, buff_v, buff_class = self.omega_buff(tracks, strategy['invite_friend'])
         buff_omega, buff_cx, buff_cy, buff_v, buff_class = self.omega_buff(tracks, strategy['invite_friend'])
         if self._omega > buff_omega:
         if self._omega > buff_omega:
             buffed = False
             buffed = False
-            target_x = self._cx + self._v * 100
+            target_x = self._cx + self._v * 100 - (self._w // 2)
             target_y = self._cy - 40
             target_y = self._cy - 40
         else:
         else:
             buffed = True
             buffed = True
@@ -116,6 +116,6 @@ velocity: {self._v}"""
         upsilon = (vector[1] / 250 - vector[2] / 35)
         upsilon = (vector[1] / 250 - vector[2] / 35)
         upsilon = 100 * (upsilon**2 if upsilon > 0 else - upsilon**2)
         upsilon = 100 * (upsilon**2 if upsilon > 0 else - upsilon**2)
         result = _omega + tau + upsilon - 0.6
         result = _omega + tau + upsilon - 0.6
-        # logger.info(f"total: {result:.4f} | {_omega:.4f} | {tau:.4f} | {upsilon:.4f}")
+        logger.info(f"total: {result:.4f} | {_omega:.4f} | {tau:.4f} | {upsilon:.4f}")
         return result
         return result
 
 

+ 10 - 1
tasks/Hyakkiyakou/script_task.py

@@ -12,6 +12,7 @@ from random import choice
 from cached_property import cached_property
 from cached_property import cached_property
 # Use cmd to install: ./toolkit/python.exe -m pip install -i https://pypi.org/simple/ oashya --trusted-host pypi.org
 # Use cmd to install: ./toolkit/python.exe -m pip install -i https://pypi.org/simple/ oashya --trusted-host pypi.org
 from oashya.tracker import Tracker
 from oashya.tracker import Tracker
+from oashya.labels import label2id
 from oashya.utils import draw_tracks
 from oashya.utils import draw_tracks
 
 
 from module.exception import TaskEnd
 from module.exception import TaskEnd
@@ -83,9 +84,17 @@ class ScriptTask(GameUi, HyaSlave):
         n = hya_config.hya_n
         n = hya_config.hya_n
         g = hya_config.hya_g
         g = hya_config.hya_g
         weights: list = [sp, ssr, sr, r, n, g]
         weights: list = [sp, ssr, sr, r, n, g]
+        str_priorities: str = hya_config.hya_priorities
+        str_priorities = str_priorities.replace(' ', '').replace(',', ',')
+        try:
+            priorities = [label2id(s) for s in str_priorities.split(',')]
+        except Exception as e:
+            logger.error(f'Priority error: {str_priorities}')
+            logger.error(e)
+            raise RequestHumanTakeover
         strategy: dict = {
         strategy: dict = {
             'weights': weights,
             'weights': weights,
-            'priorities': [],
+            'priorities': priorities,
             'invite_friend': hya_config.hya_invite_friend,
             'invite_friend': hya_config.hya_invite_friend,
             'auto_bean': hya_config.hya_auto_bean
             'auto_bean': hya_config.hya_auto_bean
         }
         }