Skip to content

Commit 8b1c343

Browse files
authored
Merge pull request #44 from ASPP/comment-rewrites
2 parents 910d882 + a21d59d commit 8b1c343

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

demo06_switching_bots.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# This bot switches its personality when one guy dies
1+
# This demo shows how to combine the strategies of the basic attacker and the
2+
# basic defender
3+
# Initially, one bot is in attack mode, while the other uses the defending
4+
# strategy. Once the attacking bot is killed, it restarts as a defender, while
5+
# the previous defender changes its personality and becomes the new attacker.
6+
7+
28
TEAM_NAME = 'Switching Bots'
39

410
import networkx
@@ -10,17 +16,22 @@
1016

1117
def init_state(personality):
1218
return {
19+
# specifies which personality we are: "attacker" or "defender"
1320
"personality": personality,
21+
22+
# entries prefixed with "attack_" are used by the move_attacker function
1423
"attack_target": None,
24+
"attack_path": None,
25+
26+
# entries prefixed with "defend_" are used by the move_defender function
1527
"defend_target": None,
1628
"defend_path": None,
17-
"attack_path": None,
1829
}
1930

2031
def move(bot, state):
2132
# Keep two "substates" — one for each bot
2233
if state == {}:
23-
# here each bopt has its own state dictionary (0 and 1) and they share
34+
# here each bot has its own state dictionary (0 and 1) and they share
2435
# the same game state information in the "graph"
2536
state['graph'] = walls_to_graph(bot.walls)
2637
state[0] = init_state("attacker")

0 commit comments

Comments
 (0)