Kaydet (Commit) 29892d84 authored tarafından Guido van Rossum's avatar Guido van Rossum

Use whrandom instead of rand.

Run 500 steps instead of forever.
üst 15527e98
...@@ -41,19 +41,19 @@ class Electrons: ...@@ -41,19 +41,19 @@ class Electrons:
self.tk.update() self.tk.update()
def random_move(self,n): def random_move(self,n):
import whrandom
c = self.canvas
for i in range(1,n+1): for i in range(1,n+1):
p = self.pieces[i] p = self.pieces[i]
c = self.canvas x = whrandom.choice(range(-2,4))
import rand y = whrandom.choice(range(-3,4))
x = rand.choice(range(-2,4))
y = rand.choice(range(-3,4))
c.move(p, x, y) c.move(p, x, y)
self.tk.update() self.tk.update()
# Run -- never returns # Run -- never returns
def run(self): def run(self):
try: try:
while 1: for i in range(500):
self.random_move(self.n) self.random_move(self.n)
except TclError: except TclError:
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment