from rute import Rute import random class Brett: def __init__(self): self._brett = [] for i in range(9): ny_rad = [] for j in range(9): ny_rad.append(Rute(i, j)) self._brett.append(ny_rad) self._skattekiste = None self.plasser_skattekiste() def plasser_skattekiste(self): tilfeldig_rad = random.randint(0, 8) tilfeldig_kolonne = random.randint(0, 8) self._skattekiste = self._brett[tilfeldig_rad][tilfeldig_kolonne] def avstand_til_skattekiste(self, rad, kolonne): return self._brett[rad][kolonne].avstand_til(self._skattekiste) def er_skattekiste(self, rad, kolonne): return self._brett[rad][kolonne] == self._skattekiste