This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
class Cell:
|
||||
|
||||
MIN_NEIGHBORS = 1
|
||||
MAX_NEIGHBORS = 4
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.neighbors = []
|
||||
|
||||
def add_neightbor(self, new_neighbor: 'Cell'):
|
||||
def add_neightbor(self, new_neighbor: "Cell"):
|
||||
self.neighbors.append(new_neighbor)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "o"
|
||||
|
||||
class StatSphere(Cell):
|
||||
|
||||
class StatSphere(Cell):
|
||||
pass
|
||||
|
||||
|
||||
class StrengthSphere(StatSphere):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""
|
||||
"""
|
||||
""" """
|
||||
|
||||
from random import choice, randint
|
||||
|
||||
from grid.sphere.cell import Cell
|
||||
|
||||
class Grid:
|
||||
|
||||
class Grid:
|
||||
def __init__(self) -> None:
|
||||
self.start = None
|
||||
|
||||
@@ -13,7 +13,7 @@ class Grid:
|
||||
self.start = cell
|
||||
|
||||
@classmethod
|
||||
def generate_grid(cls, sphere_number: int=10) -> 'Grid':
|
||||
def generate_grid(cls, sphere_number: int = 10) -> "Grid":
|
||||
# pick an impl type instead
|
||||
starting_point = Cell()
|
||||
cls.generate_neighbors(starting_point, sphere_number)
|
||||
@@ -26,5 +26,5 @@ class Grid:
|
||||
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)
|
||||
remaining_cells = max(0, remaining_cells - number_of_neighbor)
|
||||
return choice(current_cell.neighbors)
|
||||
|
||||
Reference in New Issue
Block a user