File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717# Make board updates faster
1818#
1919
20+ import random , string , traceback
21+ import curses
22+
2023class LifeBoard :
2124 """Encapsulates a Life board
2225
@@ -118,11 +121,10 @@ def display(self, update_board=1):
118121
119122 def makeRandom (self ):
120123 "Fill the board with a random pattern"
121- import whrandom
122124 self .state = {}
123125 for i in range (0 , self .X ):
124126 for j in range (0 , self .Y ):
125- if whrandom .random ()* 10 > 5.0 : self .set (j ,i )
127+ if random .random () > 0.5 : self .set (j ,i )
126128
127129
128130def erase_menu (stdscr , menu_y ):
@@ -139,7 +141,6 @@ def display_menu(stdscr, menu_y):
139141 'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit' )
140142
141143def main (stdscr ):
142- import string , curses
143144
144145 # Clear the screen and display the menu of keys
145146 stdscr .clear ()
@@ -196,7 +197,6 @@ def main(stdscr):
196197 else : pass # Ignore incorrect keys
197198
198199if __name__ == '__main__' :
199- import curses , traceback
200200 try :
201201 # Initialize curses
202202 stdscr = curses .initscr ()
You can’t perform that action at this time.
0 commit comments