Baldyr, question for you about python code

NusRa

Chieftain
Joined
May 13, 2011
Messages
16
Location
USA
Baldry,
I have a fully working .py class, so I know the issue isn't
my class define and such
I written a test method called doTest


def doTest(self, iX, iY, count):
if (count == 2):
# M = 5x5 matrix seeded with values
# I truncated it here
M = [[[-2, -2],...,[2, -2]],...,[[-2, 2],...,[2, 2]]]
else:
M = [[[-1,-1],[0,-1],[1,-1]],[[-1,0],[0,0],[1,0]],[[-1,1],[0,1],[1,1]]]
for j in range(count*2+1):
for I in range(count*2+1):
M[j][0] = iX+M[j][0]
M[j][1] = iY+M[j][1]
pInterface.addInstantMessage(str(M), "")

Then in someother method I call the doTest method
self.doTest(22, 35, 2)
Works I like a charm
When change the count var to one
it fails
If I restart the game up, count still equal to one
Works like a charm
I can even step up count to two
Still works
However if change count in self.doTest back to one
It fails again

What gives here?
I thinking it has something to do with this M array.
However should not M be private to doTest.
I copied the function and made the changes needed
to make two doTest's
One called doTest5x5 and other called doTest3x3
The script now works like a charm
When I test count in my calling method by

if (count == 2):
self.doTest5x5(22, 35, 2)
else:
self.doTest3x3(22,35,1)

Not my preferred solution, but one I can live with.
Do you have any insight with what is going on here.
I even tried
del M in the last line of orginal doTest method
thinking it is some garbage collection issue.
Thanks for your time
 
Jump the gun, apparently in cuting pasting code
I deleted or copied over a single line of code.

First doTest method has zero issues.
HappyHappy,JoyJoy
Now, I definately know I can complete
This python AI control.
Just got to loop through these coordinates and invalidate
those order pairs that the unit should not have line of sight of based
on whether unit is standing on hill or not, and whether the immediate
order pairs surrounding the unit have forest features or hills.
Take, resulting matrix, and come with an python AI decsion, of where to move the unit to, or
let the AI dll algorthms for explorers continue on its merry way, until the next set of visability orderedpairs reveal something worth trigger an action button proceedure.
Bingo, AI in python. Well one can hope.
 
Do you still need any help?

You can send me a PM next time. And always use
Code:
 tags when posting code, please.
 
Back
Top Bottom