adicionar função para mostrar mapa actual
This commit is contained in:
@ -4,6 +4,7 @@ import pygame as pg
|
||||
from modules.agente import Agente
|
||||
from modules.mapa import Mapa
|
||||
import modules.estrategia as ModEstrategia
|
||||
import modules.interaccoes as ModInteraccoes
|
||||
|
||||
flags = 0
|
||||
|
||||
@ -79,6 +80,16 @@ def mostrarEstatisticas(mapa: Mapa | None) -> None:
|
||||
(stats_estrategias[tipo_estrategia]/n_total_agentes)*100:3.2f}")
|
||||
|
||||
|
||||
def mostrarMapa(mapa: Mapa) -> None:
|
||||
# mostrar mapa com pontuação em cada posição
|
||||
for pos_y in range(0, mapa.dimensao[0]):
|
||||
for pos_x in range(0, mapa.dimensao[1]):
|
||||
tmp_agente: Agente | None = mapa.posicao((pos_x, pos_y))
|
||||
if type(tmp_agente) is not None:
|
||||
print(f"{tmp_agente.estrategia[0]:2}", end='')
|
||||
print("")
|
||||
|
||||
|
||||
def main(mapa: Mapa | None):
|
||||
if mapa is None:
|
||||
print("SEM MAPA!!")
|
||||
@ -90,6 +101,7 @@ def main(mapa: Mapa | None):
|
||||
running: bool = True
|
||||
cor1: tuple[int, int, int, int] = (255, 0, 0, 0)
|
||||
cor2: tuple[int, int, int, int] = (0, 255, 0, 0)
|
||||
mostrarMapa(mapa)
|
||||
|
||||
while running:
|
||||
for event in pg.event.get():
|
||||
@ -104,12 +116,13 @@ def main(mapa: Mapa | None):
|
||||
if event.key == pg.K_s:
|
||||
mostrarEstatisticas(mapa)
|
||||
if event.key == pg.K_n:
|
||||
# correr proxima iteracao do jogo
|
||||
pass
|
||||
ModInteraccoes.correrInteraccoesEntreAgentes(mapa)
|
||||
if event.key == pg.K_m:
|
||||
print("Mapa:")
|
||||
mostrarMapa(mapa)
|
||||
|
||||
# (367, 250)
|
||||
criarTabuleiro(janela, mapa.dimensao, mapa)
|
||||
correrInteraccoesEntreAgentes(mapa)
|
||||
pg.display.flip()
|
||||
clock.tick(60)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user