fix merge regression and exlude death player from attackable players
This commit is contained in:
15
debug.py
15
debug.py
@@ -23,16 +23,19 @@ def _random_action(Arena, Player_one):
|
|||||||
1: 'attack',
|
1: 'attack',
|
||||||
2: 'move',
|
2: 'move',
|
||||||
}
|
}
|
||||||
action= _rand.randint(1, len(_RANDOM_ACTIONS))
|
Map= Arena.get_map()
|
||||||
|
avail_actions= Map.get_player_available_actions(Player_one)
|
||||||
|
print(f'{Player_one.get_name()}:{Player_one.get_coordinates()}, avail_actions: {avail_actions}')
|
||||||
msg= ''
|
msg= ''
|
||||||
if action == 1:
|
if 1 in avail_actions:
|
||||||
# XXX maybe in future this action is available only if you are near to another player
|
# XXX maybe in future this action is available only if you are near to another player
|
||||||
# so Player_two is no more random, but will be a random near player
|
# so Player_two is no more random, but will be a random near player
|
||||||
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
preys= avail_actions[1]
|
||||||
while Player_one.get_id() == Player_two.get_id():
|
Player_two= _rand.sample(preys, 1)[0]
|
||||||
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
while Player_one.get_id() == Player_two.get_id() and not Player_two.is_alive():
|
||||||
|
Player_two= _rand.sample(preys, 1)[0]
|
||||||
_dmg, msg= Player_one.attack(Player_two)
|
_dmg, msg= Player_one.attack(Player_two)
|
||||||
elif action == 2:
|
elif 2 in avail_actions:
|
||||||
Map= Arena.get_map()
|
Map= Arena.get_map()
|
||||||
available_movements= Map.get_player_available_directions(Player_one)
|
available_movements= Map.get_player_available_directions(Player_one)
|
||||||
if not available_movements:
|
if not available_movements:
|
||||||
|
|||||||
@@ -126,12 +126,12 @@ class BrSimMap():
|
|||||||
x= coord_x + shift
|
x= coord_x + shift
|
||||||
if x < 0 or x >= self.world_width -1: continue
|
if x < 0 or x >= self.world_width -1: continue
|
||||||
resource= self.get_map_matrix()[coord_y][x]
|
resource= self.get_map_matrix()[coord_y][x]
|
||||||
if resource and resource.is_player(): attackable_players.append(resource)
|
if resource and resource.is_player() and resource.is_alive(): attackable_players.append(resource)
|
||||||
for shift in [-1, 1]:
|
for shift in [-1, 1]:
|
||||||
y= coord_y + shift
|
y= coord_y + shift
|
||||||
if y < 0 or y >= self.world_height -1: continue
|
if y < 0 or y >= self.world_height -1: continue
|
||||||
resource= self.get_map_matrix()[y][coord_x]
|
resource= self.get_map_matrix()[y][coord_x]
|
||||||
if resource and resource.is_player(): attackable_players.append(resource)
|
if resource and resource.is_player() and resource.is_alive(): attackable_players.append(resource)
|
||||||
|
|
||||||
return attackable_players
|
return attackable_players
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user