Thanks for your remarks, Alan.
And " Law of Demeter" was something new and useful for me.
This is corrected code (I hope I've understand all your remarks right):
# -*- coding: windows-1251 -*-
import random, time, Tkinter
class Agent: def __init__ (self, x=100, y=100): self.name = r
Glad you got it working.
A couple of observations:
> This is the working version of my visualization:
> class Agent:
>def __init__ (self, x=100, y=100):
>self.name = random.randint(0, 10)
>self.x = x
>self.y = y
>
>def __repr__ (self):
>return str(self.
For a quick overview of Model/View (and sometimes Controller)take a look at the Apple web site. their default GUI design uses
the paradigm and there is a good visual description in theoverview:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter02/chapter_2_section_3.h
> You will need to create a module that draws the GUI and
>> handles the user events. That module will probably
>> import this one (rather than this one importing Tkinter)
>> You can then just pass the canvas object to each object
>> in your environment and ask it to draw itself...
>
> You might li
Probably good to change the name, there is a built in class"object" and this could cause confusion...
Ok, I'll do this.
You already import Tkinter so presumabnly you want to usethat as your GUI? What other kinds of modules do you want?
You already have a display method in your object so youjust
> class Object:
Probably good to change the name, there is a built in class
"object" and this could cause confusion...
>def __init__ (self, x=10, y=10):
>def __repr__ (self):
>def display(self, canvas, x, y, width, height):
>def rand_vec(self):
>
>
> class Environment:
>def __
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, 10) self.x = x self.y = y
def __repr__ (self):