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.agente import Agente
|
||||||
from modules.mapa import Mapa
|
from modules.mapa import Mapa
|
||||||
import modules.estrategia as ModEstrategia
|
import modules.estrategia as ModEstrategia
|
||||||
|
import modules.interaccoes as ModInteraccoes
|
||||||
|
|
||||||
flags = 0
|
flags = 0
|
||||||
|
|
||||||
@ -79,6 +80,16 @@ def mostrarEstatisticas(mapa: Mapa | None) -> None:
|
|||||||
(stats_estrategias[tipo_estrategia]/n_total_agentes)*100:3.2f}")
|
(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):
|
def main(mapa: Mapa | None):
|
||||||
if mapa is None:
|
if mapa is None:
|
||||||
print("SEM MAPA!!")
|
print("SEM MAPA!!")
|
||||||
@ -90,6 +101,7 @@ def main(mapa: Mapa | None):
|
|||||||
running: bool = True
|
running: bool = True
|
||||||
cor1: tuple[int, int, int, int] = (255, 0, 0, 0)
|
cor1: tuple[int, int, int, int] = (255, 0, 0, 0)
|
||||||
cor2: tuple[int, int, int, int] = (0, 255, 0, 0)
|
cor2: tuple[int, int, int, int] = (0, 255, 0, 0)
|
||||||
|
mostrarMapa(mapa)
|
||||||
|
|
||||||
while running:
|
while running:
|
||||||
for event in pg.event.get():
|
for event in pg.event.get():
|
||||||
@ -104,12 +116,13 @@ def main(mapa: Mapa | None):
|
|||||||
if event.key == pg.K_s:
|
if event.key == pg.K_s:
|
||||||
mostrarEstatisticas(mapa)
|
mostrarEstatisticas(mapa)
|
||||||
if event.key == pg.K_n:
|
if event.key == pg.K_n:
|
||||||
# correr proxima iteracao do jogo
|
ModInteraccoes.correrInteraccoesEntreAgentes(mapa)
|
||||||
pass
|
if event.key == pg.K_m:
|
||||||
|
print("Mapa:")
|
||||||
|
mostrarMapa(mapa)
|
||||||
|
|
||||||
# (367, 250)
|
# (367, 250)
|
||||||
criarTabuleiro(janela, mapa.dimensao, mapa)
|
criarTabuleiro(janela, mapa.dimensao, mapa)
|
||||||
correrInteraccoesEntreAgentes(mapa)
|
|
||||||
pg.display.flip()
|
pg.display.flip()
|
||||||
clock.tick(60)
|
clock.tick(60)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user