-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_ia.py
executable file
·42 lines (31 loc) · 1.12 KB
/
client_ia.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
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from client.map_logic import MapLogic
from ia.ia import avoid_shoot, shoot_enemy, move
from generic_client import GenericClient
class Bot(GenericClient):
STANDALONE = False
DESIRED_FPS = 30.0 # 30 frames per second
def run_loop(self):
self.loop = LoopingCall(self.update)
self.loop.start(1.0 / self.DESIRED_FPS)
if self.STANDALONE:
reactor.run()
def load_io_handlers(self):
pass
def update(self):
avoid_shoot(self.principal, self.balas.bullets, self.conexion)
shoot_enemy(self.principal, self.hcriat.get_enemies(), self.conexion)
move(self.principal, self.conexion)
def activate_io_handlers(self):
pass
def set_principal(self, player):
self.principal = player
self.hcriat.my_team = player.equipo
def get_uid(self):
# TODO: this is just a hack, find a better approach
if self.principal:
return self.principal.uid
return 1
def create_map(self, sequence):
return MapLogic(sequence)