from codex import * from time import sleep from random import randrange def clover_3(x, y): display.fill_circle(x+34, y+80, 20, GREEN) display.fill_circle(x+76, y+80, 20, GREEN) display.fill_circle(x+55, y+50, 20, GREEN) display.fill_rect(x+50, y+55, 8, 65, GREEN) def clover_4(x, y): display.fill_circle(x+38, y+77, 20, DARK_GREEN) display.fill_circle(x+72, y+77, 20, DARK_GREEN) display.fill_circle(x+38, y+43, 20, DARK_GREEN) display.fill_circle(x+72, y+43, 20, DARK_GREEN) display.fill_rect(x+50, y+50, 8, 75, DARK_GREEN) def make_choice(num, prob): if num < prob: return True else: return False def display_choice(choice, x, y): if choice: clover_4(x, y) else: clover_3(x, y) def flash_pixels(): for i in range(5): pixels.fill(DARK_GREEN) sleep(0.25) pixels.off() sleep(0.1) # -- Main program count = 0 while True: if buttons.was_pressed(BTN_A): display.clear() count = count + 1 num = randrange(100) choice1 = make_choice(num, 20) num = randrange(100) choice2 = make_choice(num, 40) num = randrange(100) choice3 = make_choice(num, 60) display_choice(choice1, 0, 0) display_choice(choice2, 110, 0) display_choice(choice3, 55, 90) if choice1 and choice2 and choice3: text = "Number of Spins: " + str(count) display.draw_text(text, 10, 220, scale=2) flash_pixels() count = 0