Example #1
0
def main():
    '''
    Run 50 generations of a random 2-dimensional Game of Life
    
    '''

    s = '''........................O
......................O.O
............OO......OO............OO
...........O...O....OO............OO
OO........O.....O...OO
OO........O...O.OO....O.O
..........O.....O.......O
...........O...O
............OO'''
    t = s.split()

    c = life2.make_cells(50, 50, False)
    row = 3
    for cell_row in t:
        col = 3
        for cell in cell_row:
            if cell == 'O':
                c[row][col] = True
            col += 1
        row += 1

    for i in range(0, 1000):
        stddraw.show(10)
        life2.evolve(c)
        a2.draw_cells(c)

    pygame.display.quit()
    pygame.quit()
    sys.exit()
Example #2
0
def main():
    '''
    Draw 50 generations of a glider in a 2-dimensional Game of Life.
    
    '''

    n = 20
    cells = life2.make_cells(n, n, False)
    life2.glider(cells, 3, 3)

    a2.draw_cells(cells)
    for i in range(0, 50):
        stddraw.show(200)
        life2.evolve(cells)
        a2.draw_cells(cells)

    pygame.display.quit()
    pygame.quit()
    sys.exit()
Example #3
0
def main():
    '''
    Run 50 generations of a random 2-dimensional Game of Life
    
    '''
    
    n = 50
    cells = life2.make_cells(n, n, True)
    for row in range(0, n):
        for col in range(0, n):
            if random.randint(0, 1) == 0:
                cells[row][col] = False
    a2.draw_cells(cells)
    for i in range(0, n):
        stddraw.show(500)
        life2.evolve(cells)
        a2.draw_cells(cells)
        
    pygame.display.quit()
    pygame.quit()
    sys.exit()
Example #4
0
import life2

c = life2.make_cells(7, 7, False)
life2.glider(c, 0, 0)
print('cells')
life2.print_cells(c)

life2.evolve(c)
print('evolve')
life2.print_cells(c)