criação de ficheiro 'mapa.py'
definição de classe Mapa e seus metodos e propriedades
This commit is contained in:
30
modules/mapa.py
Normal file
30
modules/mapa.py
Normal file
@ -0,0 +1,30 @@
|
||||
# funções associadas a operações com o Mapa
|
||||
|
||||
from modules.agente import Agente
|
||||
|
||||
|
||||
class Mapa:
|
||||
dimensao: tuple[int, int]
|
||||
mundo: list
|
||||
|
||||
def __init__(self, dimensao: tuple[int, int]):
|
||||
self.mundo = []
|
||||
self.dimensao = dimensao
|
||||
self.mundo = self.inicializar()
|
||||
|
||||
def inicializar(self) -> list:
|
||||
# inicializar mundo
|
||||
for _ in range(0, self.dimensao[0]):
|
||||
mundo_tmp: list = []
|
||||
for _ in range(0, self.dimensao[1]):
|
||||
mundo_tmp.append(Agente())
|
||||
self.mundo.append(mundo_tmp)
|
||||
return self.mundo
|
||||
|
||||
def mostrar(self) -> None:
|
||||
# mostrar mundo
|
||||
m, n = 0, 0
|
||||
for m in range(0, self.dimensao[0]):
|
||||
for n in range(0, self.dimensao[1]):
|
||||
print(f'{self.mundo[m][n].pontuacao:2} ', end='')
|
||||
print('')
|
||||
Reference in New Issue
Block a user