Compare commits
4 Commits
8ed1bd3c4f
...
aa245700c6
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
aa245700c6 | ||
|
|
7f36158c40 | ||
|
|
171b9fe787 | ||
|
|
eb3b7da07a |
45
debug.py
45
debug.py
@@ -1,33 +1,15 @@
|
|||||||
import time as _time
|
import time as _time
|
||||||
import random as _rand
|
import random as _rand
|
||||||
import main as _main
|
import main as _main
|
||||||
|
from bot_libs import syms as _syms
|
||||||
|
|
||||||
def _debug_data():
|
def _debug_data():
|
||||||
players= [
|
players= _syms.COLORS_NAMES
|
||||||
{
|
|
||||||
'name': 'Elara',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Kaelen',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Zephyr',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Lyra',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Orion',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'Seraphina',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
weapons= []
|
weapons= []
|
||||||
|
|
||||||
Arena= _main.init_arena(players, weapons)
|
Arena= _main.init_arena()
|
||||||
print(f'Players: {Arena.get_players()}')
|
for player in players:
|
||||||
print(f'Weapons: {Arena.get_weapons()}')
|
Arena.add_player(player)
|
||||||
return Arena
|
return Arena
|
||||||
|
|
||||||
def _end_game_debug(alive_players, day):
|
def _end_game_debug(alive_players, day):
|
||||||
@@ -53,7 +35,9 @@ def _random_action(Arena, Player_one):
|
|||||||
elif action == 2:
|
elif action == 2:
|
||||||
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: return f'{Player_one.get_name()} Pensa a Guarino tutto il giorno' # XXX probably should skip this action and look for another action
|
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'
|
||||||
_rand.shuffle(available_movements)
|
_rand.shuffle(available_movements)
|
||||||
x, y, direction= available_movements[0]
|
x, y, direction= available_movements[0]
|
||||||
Player_one.move(x, y)
|
Player_one.move(x, y)
|
||||||
@@ -89,6 +73,19 @@ def play_one_day_debug(Arena):
|
|||||||
#_dmg, msg= p_one.attack(p_two)
|
#_dmg, msg= p_one.attack(p_two)
|
||||||
#return msg
|
#return msg
|
||||||
|
|
||||||
|
def init_debug_simulation():
|
||||||
|
Arena= _debug_data()
|
||||||
|
while (len(Arena.get_alive_players()) > 1):
|
||||||
|
events= play_one_day_debug(Arena)
|
||||||
|
print('#################')
|
||||||
|
print('#################')
|
||||||
|
print('#################')
|
||||||
|
print(events)
|
||||||
|
print('#################')
|
||||||
|
print('#################')
|
||||||
|
print('#################')
|
||||||
|
_time.sleep(0.3)
|
||||||
|
|
||||||
def init_debug_loop():
|
def init_debug_loop():
|
||||||
Arena= _debug_data()
|
Arena= _debug_data()
|
||||||
while (len(Arena.get_alive_players()) > 1):
|
while (len(Arena.get_alive_players()) > 1):
|
||||||
|
|||||||
@@ -115,25 +115,47 @@ class BrSimMap():
|
|||||||
avail_directions.append((0, 1, 'giu\''))
|
avail_directions.append((0, 1, 'giu\''))
|
||||||
return avail_directions
|
return avail_directions
|
||||||
|
|
||||||
def check_near_players(self):
|
def check_near_players(self, Player):
|
||||||
# TODO Implement me
|
# TODO Implement me
|
||||||
return True
|
# 1. range weapons like arch can attack from distance
|
||||||
|
# 2. knife, sword and punch can attack only on immediate near cell
|
||||||
|
|
||||||
def check_near_items(self):
|
coord_x, coord_y= Player.get_coordinates()
|
||||||
|
attackable_players= []
|
||||||
|
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]
|
||||||
|
if resource and resource.is_player(): attackable_players.append(resource)
|
||||||
|
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]
|
||||||
|
if resource and resource.is_player(): attackable_players.append(resource)
|
||||||
|
|
||||||
|
return attackable_players
|
||||||
|
|
||||||
|
def check_near_items(self, Player):
|
||||||
# TODO Implement me
|
# TODO Implement me
|
||||||
return False
|
return []
|
||||||
|
|
||||||
def get_player_available_actions(self, Player):
|
def get_player_available_actions(self, Player):
|
||||||
# TODO: define actions list
|
# TODO: define actions list
|
||||||
coord_x, coord_y= Player.get_coordinates()
|
coord_x, coord_y= Player.get_coordinates()
|
||||||
avail_actions= []
|
avail_actions= {}
|
||||||
|
|
||||||
if self.check_near_players(Player):
|
attack= self.check_near_players(Player)
|
||||||
avail_actions.append(1) #XXX replace with attack action (or maybe other actions on players)
|
if attack:
|
||||||
|
print(f'{Player.get_name()} can attack {[a.get_name() for a in attack]}')
|
||||||
|
#avail_actions.append(1) #XXX replace with attack action (or maybe other actions on players)
|
||||||
|
avail_actions[1]= attack #XXX replace with attack action (or maybe other actions on players)
|
||||||
if self.get_player_available_directions(Player):
|
if self.get_player_available_directions(Player):
|
||||||
avail_actions.append(2) #XXX replace with action move
|
avail_actions[2]= True #XXX replace with action move
|
||||||
if self.check_near_items(Items):
|
items= self.check_near_items(Player)
|
||||||
avail_actions.append(3) #XXX replace with get item action
|
if items:
|
||||||
|
avail_actions[3]= items #XXX replace with get item action
|
||||||
|
|
||||||
|
return avail_actions
|
||||||
|
|
||||||
def get_renderized_map(self):
|
def get_renderized_map(self):
|
||||||
res= ''
|
res= ''
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class BrSimPlayer(_resource.BrSimResource):
|
|||||||
self.id= str(_uuid.uuid4())
|
self.id= str(_uuid.uuid4())
|
||||||
self.name= name
|
self.name= name
|
||||||
self.stats= ''
|
self.stats= ''
|
||||||
self.health= _random.randint(1,3)
|
self.health= _random.randint(1,1)
|
||||||
self.inventory= inventory or []
|
self.inventory= inventory or []
|
||||||
self.damage= _random.randint(1,2) # this is the punch damage amount
|
self.damage= _random.randint(1,2) # this is the punch damage amount
|
||||||
self.max_weight= 5 # this is the max inventory weight
|
self.max_weight= 5 # this is the max inventory weight
|
||||||
|
|||||||
Reference in New Issue
Block a user