File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 31
31
import random , time , sys
32
32
from matplotlib import pyplot as plt
33
33
import matplotlib .animation as animation
34
+ from matplotlib .colors import ListedColormap
34
35
35
36
usage_doc = 'Usage of script: script_nama <size_of_canvas:int>'
36
37
38
+ choice = [0 ]* 100 + [1 ]* 10
39
+ random .shuffle (choice )
40
+
37
41
def create_canvas (size ):
38
42
canvas = [ [False for i in range (size )] for j in range (size )]
39
43
return canvas
@@ -102,7 +106,13 @@ def __judge_point(pt,neighbours):
102
106
seed (c )
103
107
fig , ax = plt .subplots ()
104
108
fig .show ()
105
- while True :
106
- c = run (c )
107
- ax .matshow (c )
108
- fig .canvas .draw ()
109
+ cmap = ListedColormap (['w' ,'k' ])
110
+ try :
111
+ while True :
112
+ c = run (c )
113
+ ax .matshow (c ,cmap = cmap )
114
+ fig .canvas .draw ()
115
+ ax .cla ()
116
+ except KeyboardInterrupt :
117
+ # do nothing.
118
+ pass
You can’t perform that action at this time.
0 commit comments