Now able to get AI data from the dll

NusRa

Chieftain
Joined
May 13, 2011
Messages
16
Location
USA
Looking at the python api for BtS1.71
The info base classes when called return nothing or zero
That is because they are just constructors.

However, something like
test = gc.getTerrainInfo(int TerrainType).getAIWeightPercent(int YieldType)

Returns a value one would expect the AI to be placing on a given plot
if the TerrainType is found by aplot.getTerrainType() and YieldType is zero for food

The issue however, is the value returned isn't the weight the AI placing on that given plot, but the weight the AI places on that type of plot, ie grass as a whole

The other issue is many of the python methods(attributes) that the api gives that appear to be useful are unusable, in that the self of that python method that referrences some c++ function in the corresponding .cpp, when passed along to the c function, is expecting an lvalue, that is the long int address which will contain the address of the object. python is passing along a long int that is the address of the self object, which in naturally does not contain a memory address, it is the memory address of the object.

This leaves me to believe, that many of these useful python methods, such as plot.getNaturalYield
have to be looked at in the corresponding .cpp to see what algorthim is executed and replicated in python using what methods InfoBase type classes make aviable, to come up with a psusdo AI weight that the core dllAI maybe working with to decide where to build, a farm for example.

Tomorrow, I am going to take one last shot at getting at these python api functions that when used throw a python exception no lvalue passed, by importing the ctype module in to my python class and going after these functions in dll directly.
 
Not going to be able to test going after the functions in the dll directly, since the python ctypes module is python 2.5 or better.
The only way now to make many of these apparently useful python methods in the civ python api, is to compile the source with functions that work with object addresses not just object pointers.
Now, come to think of it, the genHTML.py class that generated the api, is a brute force effort, where instead, of boting its way through the source code, it simply takes the assumption that if the source code commited that it is exposed to python, then a string construct in the genHTML.py has an entry to say that this function in the dll can be used in python.
Not always true.
 
I discovered in "Can someone explain this" thread
I been having some syntax issues.
Looking forward to getting back to those interesting python api functions, that I seemed not to be able to use.
I do believe it is possible to get at key AI values, the dll is using to make decsions with, and bring them into custom written python code, to code AI procedures to execute AI actions purely in python.

Sincerely,
NusRa
 
Back
Top Bottom