forked from Cryz/battle_royale_sim
		
	fix movements
This commit is contained in:
		
							
								
								
									
										1
									
								
								debug.py
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								debug.py
									
									
									
									
									
								
							| @@ -38,6 +38,7 @@ def _random_action(Arena, Player_one): | ||||
|   elif 2 in avail_actions: | ||||
|     Map= Arena.get_map() | ||||
|     available_movements= Map.get_player_available_directions(Player_one) | ||||
|     print(f'{Player_one.get_name()}:{Player_one.get_coordinates()}, avail_movements: {available_movements}') | ||||
|     if not available_movements: | ||||
|       # XXX probably should skip this action and look for another action | ||||
|       return f'{Player_one.get_name()} Pensa a Guarino tutto il giorno' | ||||
|   | ||||
| @@ -13,8 +13,8 @@ class BrSimMap(): | ||||
|   def __init__(self, players= None, items= None): | ||||
|     self.players= players or [] | ||||
|     self.items= items or [] | ||||
|     self.world_width= 10 #seems a reasonable width for smartphones larger maps would go on a new line | ||||
|     self.world_height= 10 | ||||
|     self.world_width= 5 #seems a reasonable width for smartphones larger maps would go on a new line | ||||
|     self.world_height= 5 | ||||
|     self.game_map= [] | ||||
|     self.field_sym= _bot_syms.MAP_UTF8_FIELD | ||||
|     self.player_male_sym= _bot_syms.MAP_UTF8_PLAYER_MALE | ||||
| @@ -105,14 +105,18 @@ class BrSimMap(): | ||||
|     coord_x, coord_y= Player.get_coordinates() | ||||
|     avail_directions= [] | ||||
|     #XXX for now move only on available cells, no over other players/items | ||||
|     if coord_x > 0 and not self.get_map_matrix()[coord_x - 1][coord_y]: | ||||
|       avail_directions.append((-1, 0, 'sinistra')) | ||||
|     if coord_x < self.world_width -1  and not self.get_map_matrix()[coord_x + 1][coord_y]: | ||||
|       avail_directions.append((1, 0, 'destra')) | ||||
|     if coord_y > 0 and not self.get_map_matrix()[coord_x][coord_y - 1]: | ||||
|       avail_directions.append((0, -1, 'su')) | ||||
|     if coord_y < self.world_height -1 and not self.get_map_matrix()[coord_x][coord_y + 1]: | ||||
|       avail_directions.append((0, 1, 'giu\'')) | ||||
|     for shift in [-1, 1]: | ||||
|       x= coord_x + shift | ||||
|       if x < 0 or x > self.world_width -1: continue | ||||
|       resource= self.get_map_matrix()[coord_y][x] | ||||
|       direction= shift == -1 and 'sinistra' or 'destra' | ||||
|       if not resource: avail_directions.append((shift, 0, direction)) | ||||
|     for shift in [-1, 1]: | ||||
|       y= coord_y + shift | ||||
|       if y < 0 or y > self.world_height -1: continue | ||||
|       resource= self.get_map_matrix()[y][coord_x] | ||||
|       direction= shift == -1 and 'su' or 'giu\'' | ||||
|       if not resource: avail_directions.append((0, shift, direction)) | ||||
|     return avail_directions | ||||
|  | ||||
|   def check_near_players(self, Player): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 andrea
					andrea