1
0

fix and improve debug game simulation

This commit is contained in:
andrea
2025-08-02 08:58:36 +02:00
parent 7f36158c40
commit aa245700c6

View File

@@ -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):
@@ -41,24 +23,21 @@ def _random_action(Arena, Player_one):
1: 'attack', 1: 'attack',
2: 'move', 2: 'move',
} }
#action= _rand.randint(1, len(_RANDOM_ACTIONS)) action= _rand.randint(1, len(_RANDOM_ACTIONS))
msg= '' msg= ''
Map= Arena.get_map() if action == 1:
avail_actions= Map.get_player_available_actions(Player_one)
#actions= list(avail_actions.keys())
#_rand.shuffle(actions)
#action= actions[0]
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
preys= avail_actions[1] Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
Player_two= _rand.sample(preys, 1)[0] while Player_one.get_id() == Player_two.get_id():
while Player_one.get_id() == Player_two.get_id() and not Player_two.is_alive(): Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
Player_two= _rand.sample(preys, 1)[0]
_dmg, msg= Player_one.attack(Player_two) _dmg, msg= Player_one.attack(Player_two)
elif 2 in avail_actions: elif action == 2:
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)
@@ -94,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):