Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add action #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 131 additions & 29 deletions config/actions_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ actions:
IDLE:
- ['delay', 0.1 ]

LIGHT_ATTACK:
LIGHT_ATTACK: &LIGHT_ATTACK
- ['press_mouse', 'left']
- ['delay', 0.14 ]
- ['release_mouse', 'left']
Expand All @@ -16,10 +16,14 @@ actions:
- ['delay', 2.53]

DRINK_POTION:
- ['press', 'space']
- ['delay', 0.16]
- ['release', 'space']
- ['delay', 0.34]
- ['press', 'r']
- ['delay', 0.12]
- ['release', 'r']
- ['delay', 1.37]
- ['delay', 1]

DODGE: &DODGE
- ['press', 'space']
Expand All @@ -28,11 +32,28 @@ actions:
- ['delay', 0.34]

DODGE_TWO: &DODGE_TWO
- *DODGE
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.2 ]
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.34 ]

DODGE_THREE: &DODGE_THREE
- *DODGE
- *DODGE_TWO
DODGE_THREE:
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.2 ]
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.2 ]
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.34 ]

ATTACK_DODGE:
- ['press_mouse', 'left']
Expand All @@ -54,11 +75,22 @@ actions:
- ['release_mouse', 'right']
- ['delay', 0.96]

THREE_HIT_COMBO: &THREE_HIT_COMBO
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.13 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.3 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.14 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.32 ]
- *DODGE

FIVE_HIT_COMBO:
- ['press_mouse', 'left']
- ['delay', 0.13 ]
- ['release_mouse', 'left']
- ['delay', 0.39]
- ['delay', 0.3]
- ['press_mouse', 'left']
- ['delay', 0.14 ]
- ['release_mouse', 'left']
Expand Down Expand Up @@ -92,42 +124,101 @@ actions:
- ['press', '3']
- ['delay', 0.16]
- ['release', '3']
- ['delay', 1.96]
- ['delay', 1.90]

SKILL_4: &SKILL_4
- ['press', '4']
- ['delay', 0.16]
- ['release', '4']
- ['delay', 1.19]

RUN_CHARGE: &RUN_CHARGE
- [ 'delay', 0.16 ]
- [ 'press_mouse', 'right' ]
- [ 'press', 'shift' ]
- [ 'delay', 0.2 ]
- [ 'press', 'd' ]
- [ 'delay', 1.45 ]
- [ 'release', 'd' ]
- [ 'press', 'w' ]
- [ 'delay', 1.45 ]
- [ 'release', 'w' ]
- [ 'press', 'a' ]
- [ 'delay', 1.45 ]
- [ 'release', 'a' ]
- [ 'press', 'w' ]
- [ 'delay', 1 ]
- [ 'release', 'w' ]
- [ 'delay', 0.2 ]
- [ 'release', 'shift' ]
- [ 'release_mouse', 'right' ]
- [ 'delay', 3.4 ]

STEALTH_CHARGE:
- *SKILL_2
- ['delay', 0.16]
- ['press_mouse', 'right']
- ['press', 'shift']
- ['delay', 0.2]
- ['press', 'd']
- ['delay', 2.45]
- ['release', 'd']
- ['press', 'w']
- ['delay', 1.45]
- ['release', 'w']
- ['press', 'a']
- ['delay', 1.45]
- ['release', 'a']
- ['press', 'w']
- ['delay', 0.45]
- ['release', 'w']
- ['delay', 0.2]
- ['release', 'shift']
- ['release_mouse', 'right']
- ['delay', 3.43]
- *RUN_CHARGE


DING_CHARGE:
- *SKILL_1
- [ 'delay', 0.16 ]
- [ 'press_mouse', 'right' ]
- [ 'press', 'shift' ]
- [ 'delay', 0.2 ]
- [ 'press', 'd' ]
- [ 'delay', 1.45 ]
- [ 'release', 'd' ]
- [ 'press', 'w' ]
- [ 'delay', 1.45 ]
- [ 'release', 'w' ]
- [ 'press', 'a' ]
- [ 'delay', 1.45 ]
- [ 'release', 'a' ]
- [ 'press', 'w' ]
- [ 'delay', 1 ]
- [ 'release', 'w' ]
- [ 'delay', 0.2 ]
- [ 'release', 'shift' ]
- [ 'release_mouse', 'right' ]
- [ 'delay', 3.4 ]

STEALTH_DRINK:
- *SKILL_2
- [ 'delay', 0.6 ]
- [ 'press', 'r' ]
- [ 'delay', 0.16 ]
- [ 'release', 'r' ]
- [ 'delay', 0.8 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.13 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 1.7 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.13 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.15 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.14 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.15 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.14 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.15 ]
- [ 'press_mouse', 'left' ]
- [ 'delay', 0.14 ]
- [ 'release_mouse', 'left' ]
- [ 'delay', 0.25 ]
- [ 'press', 'space' ]
- [ 'delay', 0.16 ]
- [ 'release', 'space' ]
- [ 'delay', 0.34 ]

FABAO:
- ['press', 't']
- ['delay', 0.16]
- ['release', 't']
- ['delay', 1.19]
- ['delay', 1.55]

TISHEN:
- ['press', 'f']
Expand Down Expand Up @@ -212,8 +303,18 @@ actions:
- ['delay', 6]
- *RUN_FORWARD

huxianfeng_restart_v2:
- *RUN_FORWARD
- [ 'press', 'w' ]
- [ 'delay', 7 ]
- ['release', 'w']
- *RUN_FORWARD
- [ 'press_mouse', 'middle' ]
- [ 'release_mouse', 'middle' ]

no_interrupts:
- STEALTH_CHARGE
- STEALTH_DRINK
- LIGHT_ATTACK
- DODGE
- IDLE
Expand All @@ -234,5 +335,6 @@ hot_list:
- SKILL_3
- FABAO
- TISHEN
- STEALTH_DRINK


81 changes: 49 additions & 32 deletions judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,65 +91,87 @@ def judge(
elif b_status["skill_4"] == False and action_name == "SKILL_4":
reward -= 100
elif b_status["skill_ts"] == False and action_name == "TISHEN":
reward -= 100
reward -= 200
elif b_status["skill_fb"] == False and action_name == "FABAO":
reward -= 100
elif b_status["skill_2"] == False and action_name == "STEALTH_CHARGE":
reward -= 100
reward -= 200
elif b_status["skill_2"] == False and action_name == "RUN_CHARGE":
reward += 100

if b_status["skill_1"] == True and action_name == "SKILL_1":
if b_status["skill_1"] == True and action_name == "DING_CHARGE":
reward += 100
elif b_status["skill_2"] == True and action_name == "SKILL_2":
reward += 100
elif b_status["skill_3"] == True and action_name == "SKILL_3":
reward += 100
if self.prev_action_name == "SKILL_1":
reward += 100
reward -= 400
elif b_status["skill_4"] == True and action_name == "SKILL_4":
reward += 100
reward -= 100
elif b_status["skill_ts"] == True and action_name == "TISHEN":
reward += 100
elif b_status["skill_fb"] == True and action_name == "FABAO":
reward += 100
elif b_status["skill_2"] == True and action_name == "STEALTH_CHARGE":
reward += 120
elif b_status["skill_2"] == True and b_status["self_blood"] < 30 and action_name == "STEALTH_DRINK":
reward += 150
elif b_status["skill_2"] == True and b_status["self_blood"] > 30 and action_name == "STEALTH_DRINK":
reward -= 200

if self.prev_injured:
if action_name == "DODGE_THREE" or action_name == "DODGE_TWO":
# 刚刚受伤了 这次优先闪避
reward += 60
elif action_name == "DRINK_POTION":
reward += 70

elif self.prev_action_name == "SKILL_1":
if action_name == "STEALTH_CHARGE" or action_name == "STEALTH_ATTACK":
reward += 100

if b_status["gunshi3"] == False and action_name == "STEALTH_ATTACK":
reward += 100

# 特殊动作规则
if action_name == "DRINK_POTION":
if b_status["self_blood"] > 90:
# 惩罚 满血 喝药
reward -= 100
# if b_status["self_blood"] > 70:
# # 惩罚 满血 喝药
# reward -= 50
if b_status["self_blood"] < 60:
# 奖励 血量低时 喝药WWW
reward += 150
elif b_status["self_blood"] < 40:
# 奖励 血量低时 喝药
reward += 50
reward += 250
elif b_status["hulu"] < 10:
# 喝光了 还在喝
reward -= 100
reward -= 50
elif action_name == "DODGE":
reward -= self.injured_index_penalty(injured, injured_cnt)
if not injured:
# 闪避 且没挨打
reward += 5
reward += 15
else:
# 闪避时间不对
reward -= 5

if self.prev_injured:
# 刚刚受伤了 这次优先闪避
reward += 10
reward -= 10
elif action_name == "QIESHOU":
if b_status["gunshi1"] == True:
# 鼓励有豆的时候使用切手 有可能打出识破
reward += 20
reward += 15
reward -= self.injured_index_penalty(injured, injured_cnt)
if not injured:
# 还没受伤 很有可能是因为识破了
reward += 30
# 还没受伤 很有可能是因为识破了
reward += 20
elif b_status["gunshi1"] == False:
reward -= 50
elif action_name == "HEAVY_ATTACK":
if b_status["gunshi1"] == False:
# 没豆 打什么重击
reward -= 20
reward -= 50
elif b_status["gunshi3"] == True:
# 鼓励下 3豆重击
reward += 20
reward += 60
if b_status["gunshi1"] == True and self.prev_action_name == "QIESHOU":
reward -= self.injured_index_penalty(injured, injured_cnt)
if not injured:
Expand All @@ -158,23 +180,18 @@ def judge(
elif action_name == "LIGHT_ATTACK":
if b_status["gunshi3"] == False:
# 没满三豆 鼓励可以攒棍势的攻击
reward += 5
reward += 25
elif action_name == "ATTACK_DODGE":
if b_status["gunshi3"] == False:
# 没满三豆 鼓励可以攒棍势的攻击
reward += 5
reward += 65
elif action_name == "FIVE_HIT_COMBO":
if b_status["gunshi3"] == False:
# 没满三豆 鼓励可以攒棍势的攻击
reward += 5
elif action_name == "SKILL_3":
if self.prev_action_name == "SKILL_1":
# 定身后 召唤猴子 安全
reward += 10
reward -= self.injured_index_penalty(injured, injured_cnt)
if injured:
# 召唤猴子的时候 挨打了 时机不对
reward -= 10
elif action_name == "RUN_CHARGE":
if b_status["gunshi3"] == False:
reward += 70

# 体能检测
if a_status["self_energy"] < 10:
Expand Down