I have a world (environment), where live different objects.
And all objects like to move.
 
This is the code:
"""

import random, time, Tkinter

class Object:
    def __init__ (self, x=10, y=10):
        self.name = random.randint(0, 100000)
        self.x = x
        self.y = y

    def __repr__ (self):
        return str(self.name)
       
    def display(self, canvas, x, y, width, height):
        """Display an image of this Object on the canvas."""
        pass

    def rand_vec(self):
        return random.randint(-1, 1), random.randint(-1, 1)
       

class Environment:
    def __init__ (self):
        self.objects = []

    def step(self):
        for obj in self.objects:
            old_x, old_y = obj.x, obj.y
            change_x, change_y = obj.rand_vec()
            obj.x, obj.y = old_x + change_x, old_y + change_y
            print obj.name, '\t:\t ', old_x, old_y,' -> ', obj.x, obj.y         

    def run(self, steps=10):
        """Run the Environment for given number of time steps."""
        for step in range(steps):
            self.step()
            time.sleep (2)         

    def add_object(self, object):
        print object.name, ' was added to environment'
        self.objects.append(object)


print '\tBORN'
env = Environment()
for obj in range(10):
    child = Object()
    print child, ' was born'
    env.add_object(child)

print '\tLIFE'
env.run(100)

"""

 

And now I want to visualizate this world.

What modules can you advise me for "easy" visualization?

"Easy" means that it would be really nice if I could do vizualization with minimum change of existing classes.

 

Thanks in advance.

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to