-
Notifications
You must be signed in to change notification settings - Fork 0
/
behavior.py
36 lines (27 loc) · 1.05 KB
/
behavior.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
class Standard:
""" Standard AI / behavior for creatures """
def __init__(self, creature):
self.me = creature
def do_stuff(self, allies, enemies):
self.me.choose_target(enemies)
if self.me.focused_enemy is not None:
self.me.choose_weapon(enemies)
at_range = self.me.move()
if at_range:
self.me.attack()
class SocialAnimal:
""" Social Animals such as wolves, lions etc. Will focus on same
target and try to keep in a pack """
def __init__(self, creature):
self.me = creature
def do_stuff(self, allies, enemies):
choice = None
for a in allies.get_alive():
if a.focused_enemy is not None and not a.focused_enemy.is_dead:
choice = a.focused_enemy
self.me.choose_target(enemies, choice)
if self.me.focused_enemy is not None:
self.me.choose_weapon(enemies)
at_range = self.me.move()
if at_range:
self.me.attack()