You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
7.8 KiB
7.8 KiB
Generating mini-games with random.choice()¶
In [2]:
from random import choice characters = ['.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '] width = 100 height = 25 for y in range(height): for x in range(width): print(choice(characters), end='') print('')
. . . . .. . . .. . . . . . . . . . . . . . . .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . .. . . . . . . . .. . . . . . . . . . .. . . . . .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . .. . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
In [130]:
from random import choice character_set = 'gamification ' characters = [character for character in character_set] width = 100 height = 25 for y in range(height): for x in range(width): print(choice(characters), end='') print('')
a o it m i i m f c c i ag n o amf f o i o i o f i a g af i g m i f a t g c f t i n o f a f tnf o f a i i i i i t in c caa t fa n f i t a i o o i ag ig g g a i i i n ag n m gt a i o f i o ni i i m i f i a a a o i m a g c f am a c o i f cna f mi t a i c f g f n i c o o g o f t a g ng i a i a n n o a t oi i it o t n o m f g a i a m ni f i i g m o i a n t a i a a m i a i a i a a ac i a t i tn t a o f tf i an i n o f i t t c g fg i o o ca i o o o m t f o i i i c i ta i ca c f c n aa g i m g m i c c i c i f i n m f i i a o i g m o ot a i a c f m i i a a i f f a c g i to in a t og im i o i f n c ao m g ii c n a to t
More games plz!¶
Try to make some more mini-games yourself.
You can restrict yourself to using ASCII characters only (see https://en.wikipedia.org/wiki/ASCII) and stay in touch with early computer graphics ASCII art...
Or you can extend your pallete with Unicode characters. This is a nice website that highlights specific character sets: http://xahlee.info/comp/unicode_index.html
In [ ]: