Facebook
From Colossal Octupus, 4 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 204
  1. import curses
  2.  
  3. class cell:
  4.     alive = False
  5.  
  6.     def arise(self):
  7.         self.alive = True
  8.  
  9.     def kill(self):
  10.         self.alive = False
  11.  
  12. class grid:
  13.     def __init__(self, height, width):
  14.             self.height = height
  15.             self.width = width
  16.             self.grid = [None for x in range(height) for y in range(width)]
  17.  
  18.     def setCell(self, y, x, cell):
  19.         self.grid[x][y] = cell
  20.  
  21.     def countAliveNeighbours(self, y, x):
  22.         c = 0
  23.  
  24. def main(screen):
  25.     num_rows, num_cols = screen.getmaxyx()
  26.     screen.addstr("cols: " + str(num_cols) + "\n")
  27.     screen.addstr("rows: " + str(num_rows))
  28.    
  29.     screen.refresh()
  30.     screen.getch()
  31.  
  32.     screen.clear()
  33.     for i in range(num_cols-1):
  34.         for j in range(num_rows-1):
  35.             screen.addstr(j, i, "x")
  36.     screen.refresh()
  37.     screen.getch()
  38.  
  39. if __name__ == "__main__":
  40.     curses.wrapper(main)