import random
from processing import *
GRID_SIZE = 12
active_grid = []
def setup():
size(900, 800)
pixel_density(2)
background(240)
initialize_cell_structure(GRID_SIZE)
class Cell(Grid):
def __init__(self, x, y, z):
self.pos = Vector(x, y, z)
self.state = 0 # empty, 1 = active
self.neighbors = get_ortho_diagonal_set()
def update(self):
count = self.grid_count_neighbors(self)
if count > 4:
self.state = 1 # Growth
elif count < 2:
self.state = 0 # Decay
def count_neighbors(grid, cell):
# Check all neighbors in self.neighbors set
c_neighbors = 0
for offset in cell.neighbors:
if grid.check_cell(pos + offset):
c_neighbors += 1
return c_neighbors
def draw_mesh_edges(self):
connect_active_cells()
def connect_active_cells():
if self.state == 1:
stroke(DEABO_STROKE_RED)
beginShape()
translate(self.pos.x, self.pos.y, self.pos.z)
draw_ring_primary_connections
# adaptive? maybe
pass
class GridStructure():
def get_neighbors(self):
return [(-1, 0, 0), (1, 0, 0), (0, -1, 0),
(0, 1, 0), (0, 0, -1), (0, 0, 1)]

No comments:
Post a Comment