File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 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+
28TEAM_NAME = 'Switching Bots'
39
410import networkx
1016
1117def 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
2031def 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" )
You can’t perform that action at this time.
0 commit comments