initial commit, nothing much here

This commit is contained in:
2024-03-06 11:34:29 +01:00
commit 787d4e776a
12 changed files with 269 additions and 0 deletions

0
grid/sphere/__init__.py Normal file
View File

22
grid/sphere/cell.py Normal file
View File

@@ -0,0 +1,22 @@
class Cell:
MIN_NEIGHBORS = 1
MAX_NEIGHBORS = 4
def __init__(self) -> None:
self.neighbors = []
def add_neightbor(self, new_neighbor: 'Cell'):
self.neighbors.append(new_neighbor)
def __str__(self) -> str:
return "o"
class StatSphere(Cell):
pass
class StrengthSphere(StatSphere):
def __init__(self) -> None:
super().__init__()

28
grid/sphere/grid.py Normal file
View File

@@ -0,0 +1,28 @@
from random import choice, randint
from grid.sphere.cell import Cell
class Grid():
def __init__(self) -> None:
self.start = None
def set_start(self, cell: Cell):
self.start = cell
@classmethod
def generate_grid(cls, sphere_number: int=10) -> 'Grid':
# pick an impl type instead
starting_point = Cell()
cls.generate_neighbors(starting_point, sphere_number)
grid = cls()
grid.set_start(starting_point)
return grid
@classmethod
def generate_neighbors(cls, current_cell: Cell, remaining_cells: int) -> Cell:
number_of_neighbor = randint(Cell.MIN_NEIGHBORS, Cell.MAX_NEIGHBORS)
for _ in number_of_neighbor:
current_cell.add_neightbor(Cell())
remaining_cells = max(0, remaining_cells-number_of_neighbor)
return choice(current_cell.neighbors)