CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of Python life game board
import random
lifechance = .1 ## 10 % chance for life in square
board = []
for x in range (50):
    # '*' == life, '' == dead
    board.append(['*' if random.random()<lifechance else ''
                  for notcare in range(50)])
# make strings for lines replacing '' values (which are considered False) with ' '
print '\n'.join(''.join(life if life else ' '
                        for life in row)
by tonyjv   August 30, 2010 @ 11:27pm
149 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate