Skip to content

Commit

Permalink
Use random module instead of whrandom
Browse files Browse the repository at this point in the history
Move imports to top
  • Loading branch information
akuchling committed Apr 10, 2002
1 parent 3b2625f commit 9a62448
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Demo/curses/life.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Make board updates faster
#

import random, string, traceback
import curses

class LifeBoard:
"""Encapsulates a Life board
Expand Down Expand Up @@ -118,11 +121,10 @@ def display(self, update_board=1):

def makeRandom(self):
"Fill the board with a random pattern"
import whrandom
self.state={}
for i in range(0, self.X):
for j in range(0, self.Y):
if whrandom.random()*10>5.0: self.set(j,i)
if random.random() > 0.5: self.set(j,i)


def erase_menu(stdscr, menu_y):
Expand All @@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit')

def main(stdscr):
import string, curses

# Clear the screen and display the menu of keys
stdscr.clear()
Expand Down Expand Up @@ -196,7 +197,6 @@ def main(stdscr):
else: pass # Ignore incorrect keys

if __name__=='__main__':
import curses, traceback
try:
# Initialize curses
stdscr=curses.initscr()
Expand Down

0 comments on commit 9a62448

Please sign in to comment.