Skip to content

Commit

Permalink
下班+排序任务合并
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Feb 13, 2025
1 parent 0fa754e commit 348b2b5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 34 deletions.
4 changes: 2 additions & 2 deletions arknights_mower/solvers/base_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ def adjust_room(self, _room):
def enter_room(self, room):
"""从基建首页进入房间"""

for enter_times in range(2):
for retry_times in range(2):
for enter_times in range(3):
for retry_times in range(5):
if pos := self.find("control_central"):
_room = segment.base(self.recog.img, pos)[room]
self.tap(self.adjust_room(_room))
Expand Down
48 changes: 28 additions & 20 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,23 +1169,21 @@ def plan_solver(self):
raise
except Exception as e:
logger.exception(e)
# 如果下个 普通任务 >5 分钟则补全宿舍
if self.find_next_task(datetime.now() + timedelta(seconds=15)):
logger.info("有其他任务,跳过宿舍纠错")
return
if self.agent_get_mood() is None:
self.backup_plan_solver()
if not self.find_next_task(datetime.now() + timedelta(minutes=5)):
try_add_release_dorm({}, None, self.op_data, self.tasks)
# 更新宿舍任务
re_order_dorm_plan = try_reorder(self.op_data)
if re_order_dorm_plan and not self.find_next_task(
datetime.now() + timedelta(minutes=0.75 * len(re_order_dorm_plan))
):
logger.info(f"新增宿舍移位任务{re_order_dorm_plan}")
if re_order_dorm_plan:
logger.debug(f"新增宿舍任务{re_order_dorm_plan}")
task = SchedulerTask(
task_plan=re_order_dorm_plan, task_type=TaskTypes.SHIFT_OFF
)
self.tasks.append(task)
if not self.find_next_task(datetime.now() + timedelta(minutes=5)):
try_add_release_dorm({}, None, self.op_data, self.tasks)
if self.find_next_task(datetime.now() + timedelta(seconds=15)):
logger.info("有其他任务,跳过宿舍纠错")
return
if self.agent_get_mood() is None:
self.backup_plan_solver()

def resting(self):
self.total_agent.sort(
Expand Down Expand Up @@ -1394,9 +1392,10 @@ def get_resting_plan(self, agents, exist_replacement, plan, current_resting):
if self.op_data.operators[x].workaholic:
continue
_dorm = self.op_data.assign_dorm(x, True)
if _dorm.position[0] not in plan.keys():
plan[_dorm.position[0]] = ["Current"] * 5
plan[_dorm.position[0]][_dorm.position[1]] = _dorm.name
# 移除宿舍任务,改由re_order一次触发
# if _dorm.position[0] not in plan.keys():
# plan[_dorm.position[0]] = ["Current"] * 5
# plan[_dorm.position[0]][_dorm.position[1]] = _dorm.name
for k, v in __plan.items():
if k not in plan.keys():
plan[k] = __plan[k]
Expand Down Expand Up @@ -1577,9 +1576,10 @@ def detect_unlock():
if pos := self.find("clue/check_party"):
logger.info("tap")
self.tap(pos)
self.party_time = self.double_read_time(
((1768, 438), (1902, 480))
)
self.party_time = self.double_read_time(
((1768, 438), (1902, 480))
)
if self.party_time > datetime.now():
logger.info(f"线索交流结束时间:{self.party_time}")
if not find_next_task(
self.tasks,
Expand All @@ -1596,7 +1596,6 @@ def detect_unlock():
self.party_time = None
logger.info("线索交流未开启")
ctm.complete("party_time")
logger.info("party_time")
else:
# 点击左下角,关闭进驻信息,进入线索界面
self.tap((330, 1000))
Expand Down Expand Up @@ -2375,7 +2374,16 @@ def choose_agent(
]
)
train_support = self.op_data.get_train_support()
free_list = list(set(free_list) - set(self.op_data.config.free_blacklist))
# 获取所有要移除的字符串集合(排除 'Crueent')
remove_set = set()
for key, value_list in self.task.plan.items():
remove_set.update(value_list) # 加入所有列表中的元素
remove_set.discard("Current")
remove_set.discard("Free")
logger.debug(f"去除被安排的人员{remove_set}")
free_list = list(
set(free_list) - set(self.op_data.config.free_blacklist) - remove_set
)
if train_support in free_list:
free_list.remove(train_support)
while free_num:
Expand Down
16 changes: 8 additions & 8 deletions arknights_mower/utils/scheduler_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ def try_reorder(op_data):

def get_ranking(name):
if name in op_data.operators:
op = op_data.operators[name]
if op.operator_type == "high" and op.resting_priority == "high":
_op = op_data.operators[name]
if _op.operator_type == "high" and _op.resting_priority == "high":
return "high"
elif op.operator_type == "high":
elif _op.operator_type == "high":
return "normal"
return "low"

Expand All @@ -435,18 +435,18 @@ def get_ranking(name):
for idx, room in enumerate(dorm) # **跳过 name 为空的 dorm**
]

def sort_key(op):
def sort_key(_op):
length = len(priority_list)
priority_order = {
"high": length,
"normal": length + 1,
"low": length + 2,
} # **先排 priority_list,再按 high > normal > low**
return (
priority_list.index(op["name"])
if op["name"] in priority_list and op["name"] != ""
else priority_order[op["priority"]],
op["index"],
priority_list.index(_op["name"])
if _op["name"] in priority_list and _op["name"] != ""
else priority_order[_op["priority"]],
_op["index"],
)

dorm_info.sort(key=sort_key)
Expand Down
1 change: 1 addition & 0 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ watch(
.n-avatar {
pointer-events: none !important;
}
.img {
pointer-events: none !important;
}
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/SlickDormSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ const props = defineProps({
}
})
// 生成宿舍列表 dormitory_x_y (x: 1-5, y: 2-5)
// 生成宿舍列表 dormitory_x_y (x: 1-4, y: 2-5)
const dormitories = computed(() => {
let options = []
for (let x = 1; x <= 5; x++) {
for (let y = 2; y <= 5; y++) {
for (let x = 1; x <= 4; x++) {
for (let y = 1; y <= 4; y++) {
const value = `dormitory_${x}_${y}`
options.push({ label: `宿舍 ${x}-${y}`, value })
options.push({ label: `宿舍 ${x}-${y + 1}`, value })
}
}
return options
Expand Down

0 comments on commit 348b2b5

Please sign in to comment.