diff options
author | Guido van Rossum <guido@python.org> | 1998-05-19 21:16:10 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-05-19 21:16:10 (GMT) |
commit | 29892d848cbe04d6e152c1c6e7e8fee7365151fd (patch) | |
tree | bb7592151964125d554872a617dd558b74234f37 | |
parent | 15527e98cd6d72150dfde5287b7ead07643b372c (diff) | |
download | cpython-29892d848cbe04d6e152c1c6e7e8fee7365151fd.zip cpython-29892d848cbe04d6e152c1c6e7e8fee7365151fd.tar.gz cpython-29892d848cbe04d6e152c1c6e7e8fee7365151fd.tar.bz2 |
Use whrandom instead of rand.
Run 500 steps instead of forever.
-rwxr-xr-x | Demo/tkinter/guido/electrons.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Demo/tkinter/guido/electrons.py b/Demo/tkinter/guido/electrons.py index f16c3fa..377c9ed 100755 --- a/Demo/tkinter/guido/electrons.py +++ b/Demo/tkinter/guido/electrons.py @@ -41,19 +41,19 @@ class Electrons: self.tk.update() def random_move(self,n): + import whrandom + c = self.canvas for i in range(1,n+1): p = self.pieces[i] - c = self.canvas - import rand - x = rand.choice(range(-2,4)) - y = rand.choice(range(-3,4)) + x = whrandom.choice(range(-2,4)) + y = whrandom.choice(range(-3,4)) c.move(p, x, y) self.tk.update() # Run -- never returns def run(self): try: - while 1: + for i in range(500): self.random_move(self.n) except TclError: try: |