Okay, now I've got a working simulation that spits out a list of lists. But when I use "from pylab import *" to run computemeans(), it creates error "'builtin_function_or_method' object has no attribute 'randrange'" on my random.randrange(0,self.width+1). Anyone see the same problem? I'm soooo close.......
I think maybe you have to say import random at the top of the file.
the simulation works completely, because random is already imported. This is why it's weird.... Not bad catch tho.
post your code?
Then maybe you've done from random import * and you don't need to say random.randrange(), you have to just say randrange().
http://codepad.org/rVbscxHN Naw, it's just import random. Thanks for trying tho!!! =) Really not sure why this problem happens between the libraries.
i just ran your file and did a quick yest of Rectangular room and it seemed to work ok http://codepad.org/c7arNxXb
I added "import pylab" to the top of your file. Then ran >>> result = runSimulation(1, 1, 5, 5, .75, 1, Robot, False) >>> r2 = computeMeans(result) and it worked. I upped the num_robots, num_trials, and room dimensions, and it still worked. The error I got before adding the pylab import was not the error you reported. Try closing all your IDLE windows, and the Python Shell. Maybe also check task manager (Windows) to see that all the pythonw.exe processes are gone. Then restart from scratch.
If that doesn't fix it, post the exact set of commands you're executing to produce the problem.
I do not know if this might be the cause of the problem you were having, but it does seem somehow pertinent. In general the statement "from <smth> import *" is dangerous, because it overrides existent method names. For example if I do from random import * from pylab import * and then call random() in my code, it is pylab.random() which is invoked. But maybe I intended to use random.random()! Since I find this disturbing, I am forcing myself not to use this command anymore (and to simply do "import <smth>").
huh..... it works now. I tried import pylab before, but it gave me another error message relating to importing pylab. So i figured i had to do a from pylab import * Well it works now, so I can continue with my work. Thanks Everyone!!!!
Join our real-time social learning platform and learn together with your friends!