project/main.py
def conway_game(colorList, random):
    """
    Creates field for Conway's Game of Life
    """

    ####################
    # Initialize field #
    ####################
    screen = pygame.display.set_mode((1280, 720), pygame.RESIZABLE)
    # screen = pygame.display.set_mode(size_monitor, pygame.RESIZABLE)
    screen.fill(black)
    conway.update(colorList[0], colorList[1], surface=screen)
    conway.transition()
    if random == "y" or random == "Y":
        conway.random_field()

    #############
    # Game Loop #
    #############
    generation = 0
    while True:
        pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))
        clock.tick(fps)
        keys = pygame.key.get_pressed()

        # Continually iterates through generations while space is held
        if keys[pygame.K_SPACE]:
            conway.transition()
            generation += 1

        # Resets field and generation to 0 using command Ctrl + R
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_r]:
            conway.reset()
            generation = 0
            pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))

        # Similar as reset above, but randomizes field using command Ctrl + T
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_t]:
            conway.reset()
            conway.random_field()
            generation = 0
            pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))

        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
                button = event.button
                if button == 1:  # change cell state with left click
                    pos = pygame.mouse.get_pos()
                    conway.click(pos)
                elif button == 3:  # iterate through next generation once with right click
                    conway.transition()
                    generation += 1
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        conway.update(colorList[0], colorList[1], surface=screen)
        pygame.display.update()

    Creates field for Conway's Game of Life
    
Creates field for Conway's Game of Life
Creates field for Conway ' s Game of Life
def conway_game(colorList, random):
    screen = pygame.display.set_mode((1280, 720), pygame.RESIZABLE)
    screen.fill(black)
    conway.update(colorList[0], colorList[1], surface=screen)
    conway.transition()
    if random == "y" or random == "Y":
        conway.random_field()
    generation = 0
    while True:
        pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))
        clock.tick(fps)
        keys = pygame.key.get_pressed()
        if keys[pygame.K_SPACE]:
            conway.transition()
            generation += 1
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_r]:
            conway.reset()
            generation = 0
            pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_t]:
            conway.reset()
            conway.random_field()
            generation = 0
            pygame.display.set_caption("Conway's Game Of Life - Generation " + str(generation))
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
                button = event.button
                if button == 1:  
                    pos = pygame.mouse.get_pos()
                    conway.click(pos)
                elif button == 3:  
                    conway.transition()
                    generation += 1
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
        conway.update(colorList[0], colorList[1], surface=screen)
        pygame.display.update()
def conway_game ( colorList , random ) : screen = pygame . display . set_mode ( ( 1280 , 720 ) , pygame . RESIZABLE ) screen . fill ( black ) conway . update ( colorList [ 0 ] , colorList [ 1 ] , surface = screen ) conway . transition ( ) if random == "y" or random == "Y" : conway . random_field ( ) generation = 0 while True : pygame . display . set_caption ( "Conway's Game Of Life - Generation " + str ( generation ) ) clock . tick ( fps ) keys = pygame . key . get_pressed ( ) if keys [ pygame . K_SPACE ] : conway . transition ( ) generation += 1 if ( keys [ pygame . K_LCTRL ] or keys [ pygame . K_RCTRL ] ) and keys [ pygame . K_r ] : conway . reset ( ) generation = 0 pygame . display . set_caption ( "Conway's Game Of Life - Generation " + str ( generation ) ) if ( keys [ pygame . K_LCTRL ] or keys [ pygame . K_RCTRL ] ) and keys [ pygame . K_t ] : conway . reset ( ) conway . random_field ( ) generation = 0 pygame . display . set_caption ( "Conway's Game Of Life - Generation " + str ( generation ) ) for event in pygame . event . get ( ) : if event . type == pygame . MOUSEBUTTONDOWN : button = event . button if button == 1 : pos = pygame . mouse . get_pos ( ) conway . click ( pos ) elif button == 3 : conway . transition ( ) generation += 1 if event . type == pygame . QUIT : pygame . quit ( ) sys . exit ( ) conway . update ( colorList [ 0 ] , colorList [ 1 ] , surface = screen ) pygame . display . update ( )
Creates field for Conway's Game of Life
Creates field for Conway ' s Game of Life
"""
    Creates field for Conway's Game of Life
    """ #################### # Initialize field # #################### # screen = pygame.display.set_mode(size_monitor, pygame.RESIZABLE) ############# # Game Loop # ############# # Continually iterates through generations while space is held # Resets field and generation to 0 using command Ctrl + R # Similar as reset above, but randomizes field using command Ctrl + T # change cell state with left click # iterate through next generation once with right click
colorList
random