Skip to content

Commit

Permalink
2025.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Jan 6, 2025
1 parent 76d8333 commit 496e81e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 41 deletions.
2 changes: 1 addition & 1 deletion arknights_mower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from pathlib import Path

__version__ = "2025.1.1"
__version__ = "2025.1.2"

if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
__rootdir__ = Path(sys._MEIPASS).joinpath("arknights_mower").resolve()
Expand Down
Binary file modified arknights_mower/resources/arrange_confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 25 additions & 11 deletions arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def overtake_room(self):
else:
msg = f"无法完成 {self.task.meta_data} 的排班,如果重复接收此邮件请检查替换组是否被占用"
send_message(msg, level="ERROR")
# 尝试挤出当前休息的
# 简单暴力一点,移除所有非回满的
# 智能情况的话,得在人数和替换冲突中做出选择
required = 0
for x in candidates:
op = self.op_data.operators[x]
Expand All @@ -227,12 +228,14 @@ def overtake_room(self):
operator = self.op_data.operators[dorm.name]
if (
operator.rest_in_full
or operator.name in self.op_data.rest_in_full_group
or operator.group in self.op_data.rest_in_full_group
):
# 如果回满,则跳过
logger.debug(f"跳过{str(dorm)},回满")
continue
# 检查是否有分组
if not operator.is_high():
# 跳过非高优
continue
if operator.group and operator.name not in remove_name:
# 增加当前宿舍组的所有在休息中的干员
for name in self.op_data.groups[operator.group]:
Expand Down Expand Up @@ -270,15 +273,22 @@ def overtake_room(self):
plan[o.room][o.index] = agent
planned.add(o.name)
logger.debug(f"生成顶替上班任务{plan}")
self.tasks.append(SchedulerTask(task_plan=plan))
# 执行完提前换班任务再次执行本任务
self.tasks.append(
SchedulerTask(
task_plan=copy.deepcopy(self.task.plan),
meta_data=self.task.meta_data,
task_type=self.task.type,
if plan:
self.tasks.append(SchedulerTask(task_plan=plan))
# 执行完提前换班任务再次执行本任务
self.tasks.append(
SchedulerTask(
task_plan=copy.deepcopy(self.task.plan),
meta_data=self.task.meta_data,
task_type=self.task.type,
)
)
)
else:
msg = (
f"无法完成 {self.task.meta_data} 的排班,请检查是否有替换组冲突"
)
logger.warning(msg)
send_message(msg, level="ERROR")
self.skip()
else:
_high_free = 0
Expand Down Expand Up @@ -2915,6 +2925,10 @@ def choose_agent(
last_special_filter = profession
if index_change:
self.switch_arrange_order(3, "true")
elif is_dorm and agent[0] == "阿米娅" and last_special_filter != "ALL":
# 如果是阿米娅且filter 不是all
self.profession_filter("ALL")
last_special_filter = "ALL"
if (
agent[0] in self.op_data.operators
and self.op_data.operators[agent[0]].is_resting()
Expand Down
51 changes: 24 additions & 27 deletions arknights_mower/utils/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def init_and_validate(self, update=False):
_dorm.agent == "Free"
and not free_found
and (dorm + str(_idx)) not in added
and len(added) < self.config.max_resting_count
):
self.dorm.append(Dormitory((dorm, _idx)))
added.append(dorm + str(_idx))
Expand All @@ -268,8 +267,6 @@ def init_and_validate(self, update=False):
for key, value in self.shadow_copy.items():
if key not in self.operators:
self.add(Operator(key, ""))
if len(self.dorm) < self.config.max_resting_count:
return f"宿舍Free总数 {len(self.dorm)}小于最大分组数 {self.config.max_resting_count}"
# 跑单
for x, y in self.plan.items():
if not x.startswith("room"):
Expand Down Expand Up @@ -528,10 +525,6 @@ def get_refresh_index(self, room, plan):
if room.startswith("dorm") and self.config.free_room:
return [i for i, x in enumerate(self.plan[room]) if x == "Free"]
for idx, dorm in enumerate(self.dorm):
# Filter out resting priority low
if idx >= self.config.max_resting_count:
if not self.config.free_room:
break
if dorm.position[0] == room:
for i, _name in enumerate(plan):
if _name not in self.operators.keys():
Expand Down Expand Up @@ -604,7 +597,9 @@ def average_mood(self):
)
return current_mood / total_mood

def available_free(self, free_type="high"):
def available_free(self, free_type="high", time=None):
if not time:
time = datetime.now()
ret = 0
freeName = []
max_count = sum(1 for key in self.plan if key.startswith("dorm"))
Expand All @@ -616,7 +611,7 @@ def available_free(self, free_type="high"):
and not self.operators[dorm.name].is_high()
):
ret += 1
elif dorm.time is not None and dorm.time < datetime.now():
elif dorm.time is not None and dorm.time < time:
logger.info(f"检测到房间休息完毕,释放{dorm.name}宿舍位")
freeName.append(dorm.name)
ret += 1
Expand All @@ -634,7 +629,7 @@ def available_free(self, free_type="high"):
and not self.operators[dorm.name].is_high()
):
ret += 1
elif dorm.time is not None and dorm.time < datetime.now():
elif dorm.time is not None and dorm.time < time:
logger.info(f"检测到房间休息完毕,释放{dorm.name}宿舍位")
freeName.append(dorm.name)
ret += 1
Expand All @@ -643,23 +638,15 @@ def available_free(self, free_type="high"):
if name in agent_list:
self.operators[name].mood = self.operators[name].upper_limit
self.operators[name].depletion_rate = 0
self.operators[name].time_stamp = datetime.now()
self.operators[name].time_stamp = time
return ret

def assign_dorm(self, name, is_new=False):
is_high = self.operators[name].resting_priority == "high"
if is_high:
_room = next(
obj
for obj in self.dorm
if obj.name not in self.operators.keys()
or not self.operators[obj.name].is_high()
)
else:
_room = None
for i in range(
4 if is_new else self.config.max_resting_count, len(self.dorm)
):
_room = None
max_count = sum(1 for key in self.plan if key.startswith("dorm"))
if not is_high:
for i in range(max_count, len(self.dorm)):
_name = self.dorm[i].name
if (
_name == ""
Expand All @@ -671,6 +658,16 @@ def assign_dorm(self, name, is_new=False):
):
_room = self.dorm[i]
break
if is_high or _room is None:
if not is_high:
logger.warning("弹性模式下请勿设置过多低优先")
_room = next(
obj
for obj in self.dorm
if obj.name not in self.operators.keys()
or not self.operators[obj.name].is_high()
or (obj.time is not None and obj.time < datetime.now())
)
_room.name = name
_room.time = None
return _room
Expand Down Expand Up @@ -812,14 +809,14 @@ def not_valid(self):
)
return False

def current_mood(self):
def current_mood(self, time=None):
if not time:
time = datetime.now()
predict = self.mood
if self.time_stamp is not None:
predict = (
self.mood
- self.depletion_rate
* (datetime.now() - self.time_stamp).total_seconds()
/ 3600
- self.depletion_rate * (time - self.time_stamp).total_seconds() / 3600
)
if 0 <= predict <= 24:
return predict
Expand Down
3 changes: 1 addition & 2 deletions arknights_mower/utils/recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def find(
color = {
"1800": (158, 958),
"12cadpa": (1810, 21),
"arrange_confirm": (755, 903),
"arrange_confirm": (963, 969),
"arrange_order_options": (1652, 23),
"arrange_order_options_scene": (369, 199),
"clue": (1740, 855),
Expand Down Expand Up @@ -741,7 +741,6 @@ def find(
"recruit/riic_res/WARRIOR": 0.7,
"recruit/time": 0.8,
"recruit/stone": 0.7,
"arrange_confirm": 0.85,
}

if res in color:
Expand Down

0 comments on commit 496e81e

Please sign in to comment.