fix and improve debug game simulation
This commit is contained in:
64
debug.py
64
debug.py
@@ -1,33 +1,15 @@
|
||||
import time as _time
|
||||
import random as _rand
|
||||
import main as _main
|
||||
from bot_libs import syms as _syms
|
||||
|
||||
def _debug_data():
|
||||
players= [
|
||||
{
|
||||
'name': 'Elara',
|
||||
},
|
||||
{
|
||||
'name': 'Kaelen',
|
||||
},
|
||||
{
|
||||
'name': 'Zephyr',
|
||||
},
|
||||
{
|
||||
'name': 'Lyra',
|
||||
},
|
||||
{
|
||||
'name': 'Orion',
|
||||
},
|
||||
{
|
||||
'name': 'Seraphina',
|
||||
},
|
||||
]
|
||||
players= _syms.COLORS_NAMES
|
||||
weapons= []
|
||||
|
||||
Arena= _main.init_arena(players, weapons)
|
||||
print(f'Players: {Arena.get_players()}')
|
||||
print(f'Weapons: {Arena.get_weapons()}')
|
||||
Arena= _main.init_arena()
|
||||
for player in players:
|
||||
Arena.add_player(player)
|
||||
return Arena
|
||||
|
||||
def _end_game_debug(alive_players, day):
|
||||
@@ -41,24 +23,21 @@ def _random_action(Arena, Player_one):
|
||||
1: 'attack',
|
||||
2: 'move',
|
||||
}
|
||||
#action= _rand.randint(1, len(_RANDOM_ACTIONS))
|
||||
action= _rand.randint(1, len(_RANDOM_ACTIONS))
|
||||
msg= ''
|
||||
Map= Arena.get_map()
|
||||
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:
|
||||
if action == 1:
|
||||
# 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
|
||||
preys= avail_actions[1]
|
||||
Player_two= _rand.sample(preys, 1)[0]
|
||||
while Player_one.get_id() == Player_two.get_id() and not Player_two.is_alive():
|
||||
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():
|
||||
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
||||
_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)
|
||||
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)
|
||||
x, y, direction= available_movements[0]
|
||||
Player_one.move(x, y)
|
||||
@@ -94,6 +73,19 @@ def play_one_day_debug(Arena):
|
||||
#_dmg, msg= p_one.attack(p_two)
|
||||
#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():
|
||||
Arena= _debug_data()
|
||||
while (len(Arena.get_alive_players()) > 1):
|
||||
|
||||
Reference in New Issue
Block a user