-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot3.py
93 lines (75 loc) · 2.46 KB
/
Bot3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Langze Lu
from Game.Skills import *
from Game.projectiles import *
from ScriptingHelp.usefulFunctions import *
from Game.playerActions import defense_actions, attack_actions, projectile_actions
from Game.gameSettings import (
HP,
LEFTBORDER,
RIGHTBORDER,
LEFTSTART,
RIGHTSTART,
PARRYSTUN,
)
# PRIMARY CAN BE: Teleport, Super Saiyan, Meditate, Dash Attack, Uppercut, One Punch
# SECONDARY CAN BE : Hadoken, Grenade, Boomerang, Bear Trap
# TODO FOR PARTICIPANT: Set primary and secondary skill here
PRIMARY_SKILL = DashAttackSkill
SECONDARY_SKILL = Grenade
# constants, for easier move return
# movements
JUMP = ("move", (0, 1))
FORWARD = ("move", (1, 0))
BACK = ("move", (-1, 0))
JUMP_FORWARD = ("move", (1, 1))
JUMP_BACKWARD = ("move", (-1, 1))
# attacks and block
LIGHT = ("light",)
HEAVY = ("heavy",)
BLOCK = ("block",)
PRIMARY = get_skill(PRIMARY_SKILL)
SECONDARY = get_skill(SECONDARY_SKILL)
CANCEL = ("skill_cancel",)
# no move, aka no input
NOMOVE = "NoMove"
# for testing
moves = (SECONDARY,)
moves_iter = iter(moves)
# TODO FOR PARTICIPANT: WRITE YOUR WINNING BOT
class Script:
def __init__(self):
self.primary = PRIMARY_SKILL
self.secondary = SECONDARY_SKILL
# DO NOT TOUCH
def init_player_skills(self):
return self.primary, self.secondary
# MAIN FUNCTION that returns a single move to the game manager
def get_move(self, player, enemy, player_projectiles, enemy_projectiles):
distance = abs(get_pos(player)[0] - get_pos(enemy)[0])
if not primary_on_cooldown(player) and distance <= prim_range(player):
return PRIMARY
elif not secondary_on_cooldown(player) and distance <= seco_range(player):
return SECONDARY
elif (
not heavy_on_cooldown(player)
and abs(get_pos(player)[0] - get_pos(enemy)[0]) <= 1
):
return HEAVY
if get_hp(player) <= 50 and distance < 2:
if distance == 1:
return BLOCK
elif get_pos(player)[0] < get_pos(enemy)[0]:
return JUMP
else:
return FORWARD
if get_hp(player) > get_hp(enemy):
if distance > 1:
if get_pos(player)[0] < get_pos(enemy)[0]:
return FORWARD
else:
return BACK
else:
return LIGHT
if get_last_move(enemy) == PRIMARY:
return JUMP_FORWARD
return LIGHT