project/main.py
def rps_game(colorList, random):
    """
    Creates field for ternary/quinary multi-state world
    """

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

    #############
    # Game Loop #
    #############
    generation = 0
    while True:
        pygame.display.set_caption(
            "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str(generation))
        clock.tick(fps)
        keys = pygame.key.get_pressed()

        # Continually iterates through generations while space is held
        if keys[pygame.K_SPACE]:
            rps.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]:
            rps.reset()
            generation = 0
            pygame.display.set_caption(
                "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - 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]:
            rps.reset()
            rps.random_field()
            generation = 0
            pygame.display.set_caption(
                "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str(generation))

        for event in pygame.event.get():
            # Rock = -1, White (background) = 0, Paper = 1, Scissors = 2, Lizard = 3, Spock = 4
            if event.type == pygame.MOUSEBUTTONDOWN:
                button, choice = event.button, 0  # default 0
                if keys[pygame.K_1]:  # Hold 1 for rock
                    choice = -1
                if keys[pygame.K_2]:  # Hold 2 for paper
                    choice = 1
                if keys[pygame.K_3]:  # Hold 3 for scissors
                    choice = 2
                if keys[pygame.K_4]:  # Hold 4 for lizard
                    choice = 3
                if keys[pygame.K_5]:  # Hold 5 for Spock
                    choice = 4

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

        rps.update(colorList[0], colorList[1], colorList[2], colorList[3], colorList[4], surface=screen)
        pygame.display.update()

    Creates field for ternary/quinary multi-state world
    
Creates field for ternary/quinary multi-state world
Creates field for ternary / quinary multi - state world
def rps_game(colorList, random):
    screen = pygame.display.set_mode((1280, 720), pygame.RESIZABLE)
    screen.fill(black)
    rps.update(colorList[0], colorList[1], colorList[2], colorList[3], colorList[4], surface=screen)
    rps.transition()
    if random == "y" or random == "Y":
        rps.random_field()
    generation = 0
    while True:
        pygame.display.set_caption(
            "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str(generation))
        clock.tick(fps)
        keys = pygame.key.get_pressed()
        if keys[pygame.K_SPACE]:
            rps.transition()
            generation += 1
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_r]:
            rps.reset()
            generation = 0
            pygame.display.set_caption(
                "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str(generation))
        if (keys[pygame.K_LCTRL] or keys[pygame.K_RCTRL]) and keys[pygame.K_t]:
            rps.reset()
            rps.random_field()
            generation = 0
            pygame.display.set_caption(
                "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str(generation))
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
                button, choice = event.button, 0  
                if keys[pygame.K_1]:  
                    choice = -1
                if keys[pygame.K_2]:  
                    choice = 1
                if keys[pygame.K_3]:  
                    choice = 2
                if keys[pygame.K_4]:  
                    choice = 3
                if keys[pygame.K_5]:  
                    choice = 4
                if button == 1:  
                    pos = pygame.mouse.get_pos()
                    rps.click(pos, choice)
                elif button == 3:  
                    rps.transition()
                    generation += 1
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
        rps.update(colorList[0], colorList[1], colorList[2], colorList[3], colorList[4], surface=screen)
        pygame.display.update()
def rps_game ( colorList , random ) : screen = pygame . display . set_mode ( ( 1280 , 720 ) , pygame . RESIZABLE ) screen . fill ( black ) rps . update ( colorList [ 0 ] , colorList [ 1 ] , colorList [ 2 ] , colorList [ 3 ] , colorList [ 4 ] , surface = screen ) rps . transition ( ) if random == "y" or random == "Y" : rps . random_field ( ) generation = 0 while True : pygame . display . set_caption ( "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str ( generation ) ) clock . tick ( fps ) keys = pygame . key . get_pressed ( ) if keys [ pygame . K_SPACE ] : rps . transition ( ) generation += 1 if ( keys [ pygame . K_LCTRL ] or keys [ pygame . K_RCTRL ] ) and keys [ pygame . K_r ] : rps . reset ( ) generation = 0 pygame . display . set_caption ( "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str ( generation ) ) if ( keys [ pygame . K_LCTRL ] or keys [ pygame . K_RCTRL ] ) and keys [ pygame . K_t ] : rps . reset ( ) rps . random_field ( ) generation = 0 pygame . display . set_caption ( "Rock, Paper, Scissors, Lizard, Spock Cellular Automata - Generation " + str ( generation ) ) for event in pygame . event . get ( ) : if event . type == pygame . MOUSEBUTTONDOWN : button , choice = event . button , 0 if keys [ pygame . K_1 ] : choice = - 1 if keys [ pygame . K_2 ] : choice = 1 if keys [ pygame . K_3 ] : choice = 2 if keys [ pygame . K_4 ] : choice = 3 if keys [ pygame . K_5 ] : choice = 4 if button == 1 : pos = pygame . mouse . get_pos ( ) rps . click ( pos , choice ) elif button == 3 : rps . transition ( ) generation += 1 if event . type == pygame . QUIT : pygame . quit ( ) sys . exit ( ) rps . update ( colorList [ 0 ] , colorList [ 1 ] , colorList [ 2 ] , colorList [ 3 ] , colorList [ 4 ] , surface = screen ) pygame . display . update ( )
Creates field for ternary/quinary multi-state world
Creates field for ternary / quinary multi - state world
"""
    Creates field for ternary/quinary multi-state world
    """ #################### # 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 # Rock = -1, White (background) = 0, Paper = 1, Scissors = 2, Lizard = 3, Spock = 4 # default 0 # Hold 1 for rock # Hold 2 for paper # Hold 3 for scissors # Hold 4 for lizard # Hold 5 for Spock # change cell state with left click # iterate through next generation once right click
colorList
random