Last active
January 28, 2021 09:55
-
-
Save joemilbourn/9cd0e922e9a9ddc8e67e68745b9d6908 to your computer and use it in GitHub Desktop.
ant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kandinsky import * | |
from random import * | |
def rcolor(): | |
return color(randint(0, 255), | |
randint(0, 255), | |
randint(0, 255)) | |
rule = [1, -1, -1, 1] | |
nr = len(rule) | |
moves = [(-1, 0), (0, -1), (1, 0), (0, 1)] | |
colors = [(0, 0, 0)] + [rcolor() for _ in range(nr-1)] | |
p = (160, 111) | |
d = 0 | |
fill_rect(0, 0, 320, 222, colors[0]) | |
while True: | |
idx = colors.index(get_pixel(*p)) | |
set_pixel(p[0], p[1], colors[(idx + 1) % nr]) | |
d = (d + rule[idx]) % len(moves) | |
p = ((p[0] + moves[d][0]) % 320, (p[1] + moves[d][1]) % 222) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment