forked from karinemiras/evoman_framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathneat_controller.py
More file actions
58 lines (49 loc) · 1.35 KB
/
neat_controller.py
File metadata and controls
58 lines (49 loc) · 1.35 KB
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
from controller import Controller
# implements controller structure for player
class player_controller(Controller):
def control(self, inputs, controller):
output = controller.activate(inputs)
# takes decisions about sprite actions
if output[0] > 0.5:
left = 1
else:
left = 0
if output[1] > 0.5:
right = 1
else:
right = 0
if output[2] > 0.5:
jump = 1
else:
jump = 0
if output[3] > 0.5:
shoot = 1
else:
shoot = 0
if output[4] > 0.5:
release = 1
else:
release = 0
return [left, right, jump, shoot, release]
# implements controller structure for enemy
class enemy_controller(Controller):
def control(self, inputs,controller):
output = controller.activate(inputs)
# takes decisions about sprite actions
if output[0] > 0.5:
attack1 = 1
else:
attack1 = 0
if output[1] > 0.5:
attack2 = 1
else:
attack2 = 0
if output[2] > 0.5:
attack3 = 1
else:
attack3 = 0
if output[3] > 0.5:
attack4 = 1
else:
attack4 = 0
return [attack1, attack2, attack3, attack4]