From a3f5c41c7c6a41dc9b5eebf31ddae686894005d2 Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Tue, 10 Sep 2024 11:03:55 +0100 Subject: [PATCH] =?UTF-8?q?cria=C3=A7=C3=A3o=20de=20ficheiro=20'mapa.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit definição de classe Mapa e seus metodos e propriedades --- modules/mapa.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 modules/mapa.py diff --git a/modules/mapa.py b/modules/mapa.py new file mode 100644 index 0000000..a67f213 --- /dev/null +++ b/modules/mapa.py @@ -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('')