Add new exercise option "easiest" and alternative priority calculation for this specific mode. May alter at a later date but for time being the behavior seems to be consistent in prioritizing the lowest average level based on all 6 ship slots (filled or empty) and lowest average overall power based on number of actual ships (only filled) in the team.

This commit is contained in:
nEEtdo0d 2020-06-14 12:27:13 -04:00
parent 0b7efe5b3a
commit 8cb55f699d
2 changed files with 17 additions and 8 deletions

View File

@ -308,7 +308,7 @@ def main(ini_name=''):
# 演习设置
exercise = daily_parser.add_argument_group('Exercise settings', 'Only support the most experience for the time being')
exercise.add_argument('--exercise_choose_mode', default=default('--exercise_choose_mode'), choices=['max_exp', 'max_ranking', 'good_opponent'], help='Only support the most experience for the time being')
exercise.add_argument('--exercise_choose_mode', default=default('--exercise_choose_mode'), choices=['max_exp', 'max_ranking', 'good_opponent', 'easiest'], help='Only support the most experience for the time being')
exercise.add_argument('--exercise_preserve', default=default('--exercise_preserve'), help='Only 0 are temporarily reserved')
exercise.add_argument('--exercise_try', default=default('--exercise_try'), help='The number of attempts by each opponent')
exercise.add_argument('--exercise_hp_threshold', default=default('--exercise_hp_threshold'), help='HHP <Retreat at Threshold')

View File

@ -9,19 +9,23 @@ from module.ui.ui import UI
OPPONENT = ButtonGrid(origin=(104, 77), delta=(244, 0), button_shape=(212, 304), grid_shape=(4, 1))
# Mode 'easiest' constants
# MAX_LVL_SUM = Max Fleet Size (6) * Max Lvl (120)
# PWR_FACTOR used to make overall PWR manageable
MAX_LVL_SUM = 720
PWR_FACTOR = 100
class Opponent:
def __init__(self, main_image, fleet_image, index):
self.index = index
self.power = self.get_power(image=main_image)
self.level = self.get_level(image=fleet_image)
self.priority = self.get_priority()
# [OPPONENT_1] ( 8256) 120 120 120 | (12356) 100 80 80
level = [str(x).rjust(3, ' ') for x in self.level]
power = ['(' + str(x).rjust(5, ' ') + ')' for x in self.power]
logger.attr(
'OPPONENT_%s, %s' % (index, str(np.round(self.priority, 3)).ljust(5, '0')),
'OPPONENT_%s' % (index),
' '.join([power[0]] + level[:3] + ['|'] + [power[1]] + level[3:])
)
@ -54,14 +58,19 @@ class Opponent:
result = power.ocr(image)
return result
def get_priority(self):
def get_priority(self, method="max_exp"):
# level = np.sum(self.level) / 6
# power = np.sum(self.power) / 6
# return level - (power - 1000) / 30
level = np.sum(self.level) / 6
return level
if method == "easiest":
level = (1 - (np.sum(self.level) / MAX_LVL_SUM)) * 100
team_pwr_div = np.count_nonzero(self.level) * PWR_FACTOR
avg_team_pwr = np.sum(self.power) / team_pwr_div
priority = level - avg_team_pwr
else:
priority = np.sum(self.level) / 6
return priority
class OpponentChoose(UI):
main_image = None
@ -81,6 +90,6 @@ class OpponentChoose(UI):
appear_button=EXERCISE_PREPARATION, skip_first_screenshot=True)
def _opponent_sort(self):
priority = np.argsort([- x.priority for x in self.opponents])
priority = np.argsort([- x.get_priority(self.config.EXERCISE_CHOOSE_MODE) for x in self.opponents])
logger.attr('Order', str(priority))
return priority