<jupyter_start><jupyter_text>Generate Game of Life Transformations  Do imports<jupyter_code>import numpy as np
import math
from numpy.random import seed
from numpy.random import randint
import pandas as pd
pd.set_option('display.max_rows', 100)<jupyter_output><empty_output><jupyter_text>Import Initial Data from Set Preloaded in DBNote that in the /gol/gol/grid_generator.py I am loading the initial data into a data store. The intention behind this is to be able to load multiple initial sets. For the purposes of this notebook and generating my algorithms for exploring this data I have also generated a simple CSV which is being imported here. Further along in this process the final application will be able to load multiple sets of data, process it over X number of generations, and then load final output for analyzation into a new data store for visualization.<jupyter_code>df = pd.read_csv('https://docs.google.com/spreadsheets/d/e/2PACX-1vTSnFfcuAFoKm1Pkpid0g4GO54yMhjdo_PxrcbvrTj2mZVSsqerWbvUQbFuhUXZv-xNxpGDnGzD6YoA/pub?output=csv')
df.head(100)
grid = []
node_list = {}
node_df = []
field_of_grid = []
for i in range(len(df)):
  grid.append([i, df['Series'][i], df['Length'][i], df['Side'][i],
               df['Node_Value'][i], df['Node_X'][i], df['Node_Y'][i],
               [df['x1'][i], df['y1'][i]], 
               [df['x2'][i], df['y2'][i]], 
               [df['x3'][i], df['y3'][i]], 
               [df['x4'][i], df['y4'][i]],
               [df['x5'][i], df['y5'][i]],
               [df['x6'][i], df['y6'][i]],
               [df['x7'][i], df['y7'][i]],
               [df['x8'][i], df['y8'][i]]
               ])
  node_list[str([df['Node_X'][i], df['Node_Y'][i]])] = df['Node_Value'][i]
  node_df.append([ [df['Node_X'][i], df['Node_Y'][i]], df['Node_Value'][i]])
field_of_grid = df
df = df.drop(['Series', 'Length', 'Side', 'Node_Value', 'Node_X', 'Node_Y'], 1)
field_of_grid = np.array(df)
field_of_node = np.array(node_df)
grid_df = pd.DataFrame(data=grid, columns=['i', 'series', 'length', 'side', 'value', 'x', 'y', 'n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7', 'n8'])
for each in range(len(node_df)):
  print(node_df[each][0])
def search_eight(x, y):
  '''
Any live cell with fewer than two live neighbours dies, as if by underpopulation.
Any live cell with two or three live neighbours lives on to the next generation.
Any live cell with more than three live neighbours dies, as if by overpopulation.
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

  '''
  global count, reproduction_list
  for each in range(len(node_df)):
    node_growth = str(node_df[each][1])
    # print("First Loop", str(node_df[each][0]), str(node_df[each][1]))
    for i in range(9 - 1):
      count = count + node_list.get(str(grid[each][i + 7]), 0)
      # print(str(grid[each][i + 7]), node_list.get(str(grid[each][i + 7]), 0), "Count:", count)
      print([node_list.get(str(grid[each][i + 7]), 0)])
    if count <= 1: node_growth = 0
    if count == 2 or 3: node_growth = 1
    if count >= 4: node_growth = 0
    count = 0

    reproduction_list.append(node_growth)

reproduction_list = []
count = 0
num = len(grid)
def parse_grid(arr):
  global num
  while num is 0:
    return
  else:
    search_eight(grid[num - 1][5], grid[num - 1][6])
    num -= 100
    # parse_grid(grid)
parse_grid(grid)
reproduction_list
# s.isin(compare[0][0][1:])

# grid = []
# node_list = []
# field_of_grid = []
# for i in range(len(df)):
#   grid.append([i, df['Series'][i], df['Length'][i], df['Side'][i],
#                df['Node_Value'][i], df['Node_X'][i], df['Node_Y'][i],
#                df['x1'][i], df['y1'][i], df['x2'][i], df['y2'][i], df['x3'][i],
#                df['y3'][i], df['x4'][i], df['y4'][i], df['x5'][i], df['y5'][i],
#                df['x6'][i], df['y6'][i], df['x7'][i], df['y7'][i], df['x8'][i],
#                df['y8'][i]])
#   node_list.append([df['Node_X'][i], df['Node_Y'][i]])
# field_of_grid = df
  # return node_list[str([x, y])]
  #if x is not [field_of_grid[num - 1][0]:
    
  #print([num - 1], [field_of_grid[num - 1][0], field_of_grid[num - 1][1]], x, y)
  # if any([field_of_grid[num - 1][0], field_of_grid[num - 1][1]] in s for s in node_list):
  #   index = node_list.index([field_of_grid[num - 1][0], field_of_grid[num - 1][1]])
  #   print('The index of e:', index)
  # else:
  #   return
  # print([field_of_grid[num - 1][0], field_of_grid[num - 1][1]], [x, y],
  #         [field_of_grid[num - 1][2], field_of_grid[num - 1][3]],[x, y],
  #         [field_of_grid[num - 1][4], field_of_grid[num - 1][5]],[x, y],
  #         [field_of_grid[num - 1][6], field_of_grid[num - 1][7]],[x, y],
  #         [field_of_grid[num - 1][8], field_of_grid[num - 1][9]],[x, y],
  #         [field_of_grid[num - 1][10], field_of_grid[num - 1][11]],[x, y],
  #         [field_of_grid[num - 1][12], field_of_grid[num - 1][13]],[x, y],
  #         [field_of_grid[num - 1][14], field_of_grid[num - 1][15]],[x, y]
  #         )<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup