Simon Says

Simon Says (or Simple Simon Says) is a children's game for three or more players. One player takes the role of "Simon" and issues instructions (usually physical actions such as "jump in the air" or "stick out your tongue") to the other players, which should be followed only when prefaced with the phrase "Simon says". Players are eliminated from the game by either following instructions that are not immediately preceded by the phrase, or by failing to follow an instruction which does include the phrase "Simon says".


Download

python-icon

        # import modules
        from random import choice
        from time import sleep
        from turtle import *
        from freegames import floor, square, vector
        pattern = []
        guesses = []
        # Create main window
        titles = {
            vector(0, 0):('red', 'dark red'),
            vector(0, -200):('blue', 'dark blue'),
            vector(-200, 0):('green', 'dark green'),
            vector(-200, -200):('yellow', 'khaki'),
        }


        def grid():
            "Draw grid of tiles."
            square(0, 0, 200, 'dark red')
            square(0, -200, 200, 'dark blue')
            square(-200, 0, 200, 'dark green')        
            square(-200, -200, 200, 'khaki')
            update()

        def flash(tile):
            "Flash tile in grid."
            glow, dark = tiles[tile]
            square(tile.x, tile.y, 200, glow)
            update()        
            sleep(0.5)
            square(tile.x, tile.y, 200, dark)
            update()        
            sleep(0.5)

        def grow():
            "Grow pattern and flash tiles."
            tile = choice(list(tiles))
            pattern.append(tile)
            
for tile in pattern: flash(tile)
print('Pattern length:', len(pattern)) guesses.clear() def tap(x, y): "Respond to screen tap." onscreenclick(None) x = floor(x, 200) y = floor(y, 200) tile = vector(x, y) index = len(guesses)
if tile != pattern[index]: exit() guesses.append(tile) flash(tile) if len(guesses) == len(pattern): grow() onscreenclick(tap) def start(x, y): "Start game." grow() onscreenclick(tap) setup(420, 420, 370, 0) hideturtle() tracer(False) grid() onscreenclick(start) done()