Page 8 of 11
Posted: 17 Jun 2005, 05:41
by t9999clint
AF I see the logic in your need to keep your source mostly closed, however as I see things, a fully open source project (using something like a cvs system) is a LOT more likely to be completed and to have more people join and help out. (for example, MPlayer, EMule, MegaMek, etc...)
your efforts seemed to be somewhat overcontroling, which may be good sometimes, but this usualy slows a groups wilingness to change there coding concepts for a more efficent system.
However, as for the progress that I read of, I thank you for your good work and hope the AI gets completed soon. ^_^
Goodluck!
Posted: 17 Jun 2005, 10:00
by AF
And I thank you for your compliments. Although I'm curious what would it take to setup a cvs? Note that I cant host anythign on ym own computer as my grandparent are fussy over power usage.
Posted: 17 Jun 2005, 19:41
by t9999clint
I'll take a look, but I'm pretty certian that sourceforge will host it for you. But don't quote me on this cause I'm not to sure yet.
sf.net and CVS
Posted: 17 Jun 2005, 20:49
by munch
t9999clint wrote:I'll take a look, but I'm pretty certian that sourceforge will host it for you. But don't quote me on this cause I'm not to sure yet.
I'm sure sourceforge would be more than happy to host - I've never known them turn a project down.
CVS is fairly straightforward to use. If you haven't used it before, an excellent windows client is tortoise CVS
http://www.tortoisecvs.org/.
tortoise CVS is particularly good place to start as it enables you to create a local CVS repository on your hard disk that you can have a play around with yourself, to get to know how CVS works.
Using CVS with source forge is a bit more complicated because of the way they handle connections to the server (ssh). Still, there's plenty of documentation on site, and the support from the system admins isn't bad considering its free!
I hope this helps.
Posted: 20 Jun 2005, 12:57
by AF
I get back form my parents house soon so I'll look into sourceforge when I can....
Developer of GlobalAI (SJ), please add those functions:
Posted: 22 Jun 2005, 18:53
by alik83
To developer of GlobalAI (SJ), please add those functions to globalAI interface, that haven't been mentioned before:
1) GetRadarBlips - get all enemy radar blips, their positions (might include inacuracy) and (maybe their speed/direction- not necessary).
2)String GetUserInput() - would be good for groupAI too- get player's chat message, so he can for example enter some commands and variable values in chat, determining AI behaviour during game- I found many uses for that! I think it's a must! (The code for that looks to be not so easy as I first thought)
Not extremely necessary:
3) Get the pathfinder map info like when you press F2, to determine passable/unpassable areas for kbot/vech.
4)Could there be a function, determining where from approximately an enemy's projectile/Nuke is hitting?
Posted: 23 Jun 2005, 06:18
by [K.B.] Napalm Cobra
3 is already implemented.
Posted: 23 Jun 2005, 13:37
by AF
Or to see what projectiles are actually entransit.
Also a modification fo GroupAI so that we can send messages and requests betwen them.
Posted: 14 Jul 2005, 20:04
by jcnossen
I've a couple of requests for the global AI interface that I'd like to see implemented:
- Access to the virtual filesystem, to scan for files with certain extensions.
- Something like IGlobalAICallback::GetMapName () so I can cache generated map information.
thx
The Global AI API
Posted: 21 Jul 2005, 14:21
by munch
Could somebody actually post the Global AI API here so that we can reference it if needed when making posts? It would be handy if it was in a sticky thread all on its own (it could replace this thread in fact)
Ta
Munch
Posted: 21 Jul 2005, 15:42
by AF
GlobalAI interface
Code: Select all
class IGlobalAI
{
public:
virtual void InitAI(IGlobalAICallback* callback, int team)=0;
virtual void UnitCreated(int unit)=0; //called when a new unit is created on ai team
virtual void UnitFinished(int unit)=0; //called when an unit has finished building
virtual void UnitDestroyed(int unit)=0; //called when a unit is destroyed
virtual void EnemyEnterLOS(int enemy)=0;
virtual void EnemyLeaveLOS(int enemy)=0;
virtual void EnemyEnterRadar(int enemy)=0; //called when an enemy enter radar coverage (not called if enemy go directly from not known -> los)
virtual void EnemyLeaveRadar(int enemy)=0; //called when an enemy leave radar coverage (not called if enemy go directly from inlos -> now known)
virtual void UnitIdle(int unit)=0; //called when a unit go idle and is not assigned to any group
virtual void GotChatMsg(const char* msg,int player)=0; //called when someone writes a chat msg
virtual void UnitDamaged(int damaged,int attacker,float damage,float3 dir)=0; //called when one of your units are damaged
//called every frame
virtual void Update()=0;
};
GlobalAI Callback interface
Code: Select all
class IGlobalAICallback
{
public:
// returns the size of the created area, this is initialized to all 0 if not previously created
//set something to !0 to tell other ais that the area is already initialized when they try to create it
//the exact internal format of the memory areas is up to the ais to keep consistent
virtual void* CreateSharedMemArea(char* name, int size)=0;
//release your reference to a memory area.
virtual void ReleasedSharedMemArea(char* name)=0;
virtual int CreateGroup(char* dll)=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 const std::vector<CommandDescription>* GetGroupCommands(int groupid)=0; //the commands that this group can understand, other commands will be ignored
virtual int GiveGroupOrder(int groupid, Command* c)=0;
virtual void SendTextMsg(const char* text, int priority)=0;
virtual int GetCurrentFrame()=0;
virtual int GetMyTeam()=0;
virtual int GetMyAllyTeam()=0;
virtual int GiveOrder(int unitid, Command* c)=0;
virtual const std::vector<CommandDescription>* GetUnitCommands(int unitid)=0; //the commands that this unit can understand, other commands will be ignored
virtual const std::deque<Command>* GetCurrentUnitCommands(int unitid)=0; //the commands that this unit has currently qued
// as per the Group AI, these return 0 if you don't have los to the unit in question
virtual int GetUnitAiHint(int unitid)=0;
virtual int GetUnitGroup(int unitid)=0; //returns the group a unit belongs to, -1 if no group
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.0-1.0)
virtual float GetUnitMaxRange(int unitid)=0; //the furthest any weapon of the unit can fire
virtual const UnitDef* GetUnitDef(int unitid)=0; //this returns the units unitdef struct from which you can read all the statistics of the unit, dont try to change any values in it, dont use this if you dont have to risk of changes in it
virtual const UnitDef* GetUnitDef(const char* unitName)=0;
//this will return a value even if you only have radar to it, but it might be wrong
virtual float3 GetUnitPos(int unitid)=0; //note that x and z are the horizontal axises while y represent height
//the following functions allows the dll to use the built in pathfinder
//call InitPath and you get a pathid back
//use this to call GetNextWaypoint to get subsequent waypoints, the waypoints are centered on 8*8 squares
//note that the pathfinder calculates the waypoints as needed so dont retrieve them until they are needed
//the waypoints x and z coordinate is returned in x and z while y is used for error codes
//>=0 =worked ok,-2=still thinking call again,-1= end of path reached or invalid path
virtual int InitPath(float3 start,float3 end,int pathType)=0;
virtual float3 GetNextWaypoint(int pathid)=0;
virtual void FreePath(int pathid)=0;
//This function returns the approximate path cost between two points(note that it needs to calculate the complete path so its somewhat expansive)
virtual float GetPathLength(float3 start,float3 end,int pathType)=0;
//the following function return the units into arrays that must be allocated by the dll
//10000 is currently the max amount of units so that should be a safe size for the array
//the return value indicates how many units was returned, the rest of the array is unchanged
virtual int GetEnemyUnits(int *units)=0; //returns all known enemy units
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)=0; //returns all friendly units
virtual int GetFriendlyUnits(int *units,const float3& pos,float radius)=0; //returns all friendly units within radius from pos
//the following functions are used to get information about the map
//dont modify or delete any of the pointers returned
//the maps are stored from top left and each data position is 8*8 in size
//to get info about a position x,y look at location
//(int(y/8))*GetMapWidth()+(int(x/8))
//some of the maps are stored in a lower resolution than this though
virtual int GetMapWidth()=0;
virtual int GetMapHeight()=0;
virtual const float* GetHeightMap()=0; //this is the height for the center of the squares, this differs slightly from the drawn map since it uses the height at the corners
virtual const unsigned short* GetLosMap()=0; //a square with value zero means you dont have los to the square, this is half the resolution of the standard map
virtual const unsigned short* GetRadarMap()=0; //a square with value zero means you dont have radar to the square, this is 1/8 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 unsigned char* GetMetalMap()=0; //this map shows the metal density on the map, this is half the resolution of the standard map
virtual float GetElevation(float x,float z)=0; //Gets the elevation of the map at position x,z
//this function allows you to draw units in the map, of course they dont really exist,they just show up on the local players screen
//they will be drawn in the standard pose before any scripts are run
//the rotation is in radians,team affects the color of the unit
virtual void DrawUnit(const char* name,float3 pos,float rotation,int lifetime,int team,bool transparent,bool drawBorder)=0;
virtual bool CanBuildAt(const UnitDef* unitDef,float3 pos)=0; //returns true if a given type of unit can be build at a pos (not blocked by other units etc)
virtual float3 ClosestBuildSite(const UnitDef* unitdef,float3 pos,float searchRadius,int minDist)=0; //returns the closest position from a position that the building can be built, minDist is the distance in squares that the building must keep to other buildings (to make it easier to create paths through a base), returns x=-1 if a pos is not found
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
};
GroupAI interface
Code: Select all
class IGroupAI
{
public:
virtual void InitAi(IGroupAiCallback* callback)=0;
virtual bool AddUnit(int unit)=0; //group should return false if it doenst want the unit for some reason
virtual void RemoveUnit(int unit)=0; //no way to refuse giving up a unit
virtual void GiveCommand(Command* c)=0; //the group is given a command by the player
virtual const vector<CommandDescription>& GetPossibleCommands()=0; //the ai tells the interface what commands it can take (note that it returns a reference so it must keep the vector in memory itself)
virtual int GetDefaultCmd(int unitid)=0; //the default command for the ai given that the mouse pointer hovers above unit unitid (or no unit if unitid=0)
virtual void CommandFinished(int unit,int type)=0; //a specific unit has finished a specific command, might be a good idea to give new orders to it
virtual void Update()=0; //called once a frame (30 times a second)
};
New API
Posted: 22 Jul 2005, 22:15
by munch
Can somebody post the new API? Ta =)
MUnch
Posted: 22 Jul 2005, 22:30
by AF
Posted: 22 Jul 2005, 23:17
by munch
Thanks =)
Posted: 06 Oct 2005, 23:45
by cain
alik83
2)String GetUserInput()
it's there already:
virtual void GotChatMsg(const char* msg,int player)=0;
Posted: 13 Nov 2005, 11:13
by daraknor
I had some requests for the AI interface, posted at
http://taspring.clan-sy.com/phpbb/viewtopic.php?t=2840
Also, this seems like a very silly question since NTAI 0.27b constantly spits error messages at me, but is there a way to use the chat dialog for the AI to get messages? I was thinking of using the chat dialog to have player<->AI interaction for coordinating attacks, defense and so on.
Posted: 13 Nov 2005, 17:43
by AF
You could do that.
If the AI is spitting errors at you and you havent turned on verbose mode then those are exceptions. I fixeda few exceptions that where being caught this mornign and found a rather nasty surprise as to why the attack code is broken.
Any attempt to get what enemy untis are in range of LOS or Radar fails, as the returned arrays always have 0 units in them.
If a unti eneters LOS ro radar and EnemyEnteredLOS is called, I used to eb able to get its position cus ti was now in LOS/radar. Not any longer. The onyl way i can figure out that i can get an enemy untis position is through the untidamaged parameters.
Thus NTAI has workign attack code that is being fed misinformation.
I also found that zaphod has commented out the pathlength function, so it always returns 0, which breaks some of my attack code too.
As long as you're in the top left corner of the map you shouldnt see this problem unless you move your base though.
I'll continue changing thigns around to see if I can get results, for example I've cut down logfile sizes by 60%, and added more checks and rebalanced some things so they work better.
Posted: 13 Nov 2005, 18:04
by jcnossen
I also found that zaphod has commented out the pathlength function, so it always returns 0, which breaks some of my attack code too.
It was never not commented out, so I don't see how this attack code has ever worked. In any case I did not break it.
Posted: 13 Nov 2005, 18:27
by AF
ahem, look at the source file distributed on the downlaods page and look at the function in rts/AICallback.cpp
It has the code commented out and return 0; underneath.
And I'm unsure how but my AI cant get the positions of units that've just come into LOS, or units currently in LOS. As a result the checks in the attack code get given 0,0,0 locations by default and the attack code mvoes the goup to 0,0,0 rather than attacking unit x because from what it is told there arent any units in LOS and radar belonging to the enemy.
Whether you commented ti or not I suggest you go see why it was commented. If not you perhaps alik did it or submarine? I knwo not fo anyone else touchign the interface code.
Posted: 13 Nov 2005, 21:08
by jcnossen
Read my post, I'm saying it's commented out, I'm also saying it was never not commented out. SJ or Jouninkomiko (the one who did the initial AI interface) did this for some reason. I'll try and fix it though...