Page 2 of 3
Posted: 14 Dec 2006, 14:14
by Kloot
Ah, those headers aren't covered by the ABIC layer, so that might explain the crashes when using it... I wouldn't know what's causing them with the standard interface though, does your AI perhaps export the function "IsCInterface"?
Posted: 15 Dec 2006, 00:58
by AF
Firstly
DevC++ AIs crash spring.
Codeblocks AIs are better.
Secondly, a few things about the C ABI
This only works for Skirmish AIs, and wont work for GroupAI.
Also there are a few items missing from the ABI, and a huge list missing from the c++ wrappers.
namely:
Code: Select all
virtual void SendTextMsg(const char* text,int priority) = 0;
virtual void SetLastMsgPos(float3 pos) = 0;
virtual void AddNotification(float3 pos, float3 color, float alpha) = 0;
virtual bool PosInCamera(float3 pos, float radius) = 0; // checks if pos is within view of the current camera, using radius as a margin
//get the current game time, there is 30 frames per second at normal speed
virtual int GetCurrentFrame() = 0;
virtual int GetMyTeam()=0;
virtual int GetMyAllyTeam()=0;
virtual int GetPlayerTeam(int player) = 0;
virtual void* CreateSharedMemArea(char* name, int size)=0;
virtual void ReleasedSharedMemArea(char* name)=0;
virtual int CreateGroup(char* dll,unsigned aiNumber) = 0; //creates a group and return the id it was given, return -1 on failure (dll didnt exist etc)
virtual void EraseGroup(int groupid) = 0; //erases a specified group
virtual bool AddUnitToGroup(int unitid,int groupid) = 0; //adds a unit to a specific group, if it was previously in a group its removed from that, return false if the group didnt exist or didnt accept the unit
virtual bool RemoveUnitFromGroup(int unitid) = 0; //removes a unit from its group
virtual int GetUnitGroup(int unitid) = 0; //returns the group a unit belongs to, -1 if no group
virtual const std::vector<CommandDescription>* GetGroupCommands(int unitid) = 0; //the commands that this unit can understand, other commands will be ignored
virtual int GiveGroupOrder(int unitid, Command* c) = 0;
virtual const vector<CommandDescription>* GetUnitCommands(int unitid) = 0;
virtual const deque<Command>* GetCurrentUnitCommands(int unitid) = 0;
virtual int GetUnitAiHint(int unitid) = 0; //integer telling something about the units main function, not implemented yet
virtual int GetUnitTeam(int unitid) = 0;
virtual int GetUnitAllyTeam(int unitid) = 0;
virtual float GetUnitHealth(int unitid) = 0; //the units current health
virtual float GetUnitMaxHealth(int unitid) = 0; //the units max health
virtual float GetUnitSpeed(int unitid) = 0; //the units max speed
virtual float GetUnitPower(int unitid) = 0; //sort of the measure of the units overall power
virtual float GetUnitExperience(int unitid) = 0; //how experienced the unit is (0.0f-1.0f)
virtual float GetUnitMaxRange(int unitid) = 0; //the furthest any weapon of the unit can fire
virtual bool IsUnitActivated (int unitid) = 0;
virtual bool UnitBeingBuilt(int unitid) = 0; //returns true if the unit is currently being built
virtual int GetBuildingFacing(int unitid) = 0; //returns building facing (0-3)
virtual bool IsUnitCloaked(int unitid) = 0;
virtual bool IsUnitParalyzed(int unitid) = 0;
virtual bool GetUnitResourceInfo(int unitid, UnitResourceInfo* resourceInfo) = 0;
virtual const UnitDef* GetUnitDef(const char* unitName) = 0;
virtual int InitPath(float3 start,float3 end,int pathType) = 0;
virtual float3 GetNextWaypoint(int pathid) = 0;
virtual void FreePath(int pathid) = 0;
virtual float GetPathLength(float3 start,float3 end,int pathType)=0;
virtual int GetEnemyUnits(int *units)=0; //returns all known enemy units (all in los)
virtual int GetEnemyUnits(int *units,const float3& pos,float radius)=0; //returns all known enemy units within radius from pos
virtual int GetFriendlyUnits(int *units,const float3& pos,float radius)=0; //returns all friendly units within radius from pos
virtual int GetMapWidth()=0;
virtual int GetMapHeight()=0;
virtual float GetMinHeight()=0; // readmap->minHeight
virtual float GetMaxHeight()=0; // readmap->maxHeight
virtual const float* GetSlopeMap()=0; // slopemap, half the resolution of the standard map
virtual const unsigned short* GetJammerMap()=0; //a square with value zero means you dont have radar jamming on the square, this is 1/8 the resolution of the standard map
virtual const char* GetMapName()=0;
virtual const char* GetModName()=0;
virtual float GetElevation(float x,float z)=0; //Gets the elevation of the map at position x,z
virtual float GetMaxMetal()=0; //returns what metal value 255 in the metal map is worth
virtual float GetExtractorRadius()=0; //returns extraction radius for metal extractors
virtual float GetMinWind()=0;
virtual float GetMaxWind()=0;
virtual float GetTidalStrength()=0;
virtual float GetGravity()=0;
virtual void LineDrawerStartPath(const float3& pos, const float* color)=0;
virtual void LineDrawerFinishPath()=0;
virtual void LineDrawerDrawLine(const float3& endPos, const float* color)=0;
virtual void LineDrawerDrawLineAndIcon(int cmdID, const float3& endPos, const float* color)=0;
virtual void LineDrawerDrawIconAtLastPos(int cmdID)=0;
virtual void LineDrawerBreak(const float3& endPos, const float* color)=0;
virtual void LineDrawerRestart()=0;
virtual void LineDrawerRestartSameColor()=0;
virtual int CreateSplineFigure(float3 pos1,float3 pos2,float3 pos3,float3 pos4,float width,int arrow,int lifetime,int group)=0;
virtual void SetFigureColor(int group,float red,float green,float blue,float alpha)=0;
virtual void DeleteFigureGroup(int group)=0;
virtual bool GetProperty(int id, int property, void *dst)=0;
virtual bool GetValue(int id, void *dst)=0;
virtual int HandleCommand(int commandId, void *data)=0;
virtual int GetFileSize (const char *name)=0;// return -1 when the file doesn't exist
virtual bool ReadFile (const char *name, void *buffer,int bufferLen)=0;
virtual int GetSelectedUnits(int *units)=0;
virtual float3 GetMousePos()=0;
virtual int GetMapPoints(PointMarker *pm, int maxPoints)=0;
virtual int GetMapLines(LineMarker *lm, int maxLines)=0;
virtual float GetMetal() = 0; //stored metal for team
virtual float GetMetalIncome() = 0;
virtual float GetMetalUsage() = 0;
virtual float GetMetalStorage() = 0; //metal storage for team
virtual float GetEnergy() = 0; //stored energy for team
virtual float GetEnergyIncome() = 0;
virtual float GetEnergyUsage() = 0;
virtual float GetEnergyStorage() = 0; //energy storage for team
virtual int GetFeatures (int *features, int max, const float3& pos, float radius) = 0;// GetFeaturesAt
virtual float GetFeatureHealth (int feature) = 0;
virtual float GetFeatureReclaimLeft (int feature) = 0;
virtual int GetNumUnitDefs() = 0;
virtual void GetUnitDefList (const UnitDef** list) = 0;
virtual float GetUnitDefHeight(int def) = 0; // forces loading of the unit model
virtual float GetUnitDefRadius(int def) = 0; // forces loading of the unit model
virtual const WeaponDef* GetWeapon(const char* weaponname) = 0;
By far the best choice is to just compile in Mingw32 or develop in C#.
Posted: 15 Dec 2006, 01:42
by Bobcatben
is there a way to make devc++ or vc++ use mingw? devc++ has it in its installation
Posted: 15 Dec 2006, 01:48
by AF
The vesion of mingw32 in devc++ is really old.
Use codeblocks instead.
And you can get VS to use mingw32 if you really want to but its a nasty process.
Compile spring and your AI in VS to test and compile with mingw32 for release.
Posted: 15 Dec 2006, 01:51
by Bobcatben
whats weird is, one of my groupais compiles and runs fine with g++ in devc++, but the other doesnt, and the reason i dont use mingw is because ive never directly used a compiler in windows, only through a IDE.
Posted: 15 Dec 2006, 01:55
by AF
NTai compiled under Devc++ crashes at startup trying to parse the unit learning data.
The same code runs perfectly when compiled in VS 2003 or the mingw32 that comes with codeblocks.
Posted: 15 Dec 2006, 06:37
by ILMTitan
Has anyone here tried using Eclipse as their C++ IDE. I love it for Java, but don't really know how well the C++ plugin works.
Posted: 15 Dec 2006, 14:54
by imbaczek
AF wrote:The vesion of mingw32 in devc++ is really old.
Use codeblocks instead.
No need, just overwrite devcpp's gcc and other stuff with recent mingw stuff (
http://www.mingw.org).
Posted: 16 Dec 2006, 04:56
by Bobcatben
hmm, i upgraded the mingw in devc++, still, one of my ais works fine, and one crashes, while back when vc++ compiles worked, they both worked, without any code changes since then.
Posted: 16 Dec 2006, 05:00
by AF
I'd still use codeblocks as its by far a better IDE, devc++ just hasnt been updated for so long its not worth it.
Also try debugging it, it may be your code not your compiler.....
Posted: 17 Dec 2006, 04:21
by Erom
ILMTitan wrote:Has anyone here tried using Eclipse as their C++ IDE. I love it for Java, but don't really know how well the C++ plugin works.
I'd also love to hear opinions on this.
Posted: 18 Dec 2006, 01:10
by Bobcatben
hmm, well iupgraded the mingw in devc++, my 2nd of 3 AIs still crash on loading, the first one works perfectly, the 3rd one works, but spring does the runtime crash when shift is pressed after my AI is loaded, but the first AI of the 3 doesnt crash it when its pressed... so weird

Posted: 18 Dec 2006, 01:34
by imbaczek
Erom wrote:ILMTitan wrote:Has anyone here tried using Eclipse as their C++ IDE. I love it for Java, but don't really know how well the C++ plugin works.
I'd also love to hear opinions on this.
Code completion is so slow it's practically unusable, and that's the only imaginable reason I'd want to work on C++ in Eclipse.
Posted: 18 Dec 2006, 02:06
by Bobcatben
ok so, apparently, mingw's version of deque isnt smart enough not to execute pop_front, if its empty..... and was crashing it..., and low and behold now that the second of 3 ais loads and works, it doesnt crash from shift, but the 3rd does... and its the simplest of any of my ais... how odd
Posted: 18 Dec 2006, 02:20
by AF
oddly enough none of them do, I had this bug in my early days using Visual Studio...
Posted: 18 Dec 2006, 02:23
by Bobcatben
well, my visual studio 2003's version is smart enough, but anyway, that ai works now, now im just stumped as to why the shift key crashes my nano tower manager AI
Posted: 18 Dec 2006, 02:26
by AF
Check your DLLEXPORT bool IsUnitSuited() function
Posted: 18 Dec 2006, 02:32
by Bobcatben
Code: Select all
DLL_EXPORT bool IsUnitSuited(unsigned aiNumber, const UnitDef* unitDef)
{
return true;
}
the same as the rest of my groupais
Edit: fixed it, i got no more problems now, apparently mingw's version of vectors dont initialize themselves when created, so a commands.clear() in initAI fixed it.
Posted: 18 Dec 2006, 04:42
by Bobcatben
its all fixed, but i have a few of questions.
1: why is the build distance from unitdef slightly larger then the real allowable builddistance, i noticed in my nanotower manager, when it tries to reclaim something near the edge of its builddistance, it thinks it has to walk there, which it cant.
2: is there a way to tell if a wreckage was built(like dragons teeth) or from a unit dieing.
3: is there a way to tell what the unit id is of what a unit is building(not the unitdef id, but ingame id) or what a unit is currently doing.
Posted: 18 Dec 2006, 12:43
by AF
2: is there a way to tell if a wreckage was built(like dragons teeth) or from a unit dieing.
3: is there a way to tell what the unit id is of what a unit is building(not the unitdef id, but ingame id) or what a unit is currently doing.
Figuring this out would require a parent global AI acting in tandem as a silent watcher, else the groupAI just doesnt have the necessary information available, nor the scope to derive it. It would need tor ecieve the full range of events from the entire game as and when ti happens regardless of wether a unit is under its control.
although n#1 and n#2 can still be subtly derived using inference, aka unit A has a command to build X at position Y and an unfinished unit B is at X of type Y.....