More AI Interface Questions (maybe not java specific)

More AI Interface Questions (maybe not java specific)

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
casperjeff
Posts: 51
Joined: 14 Aug 2008, 21:54

More AI Interface Questions (maybe not java specific)

Post by casperjeff »

In the ecconomy object...what is the difference between the values returned by:

getCurrent(Resource c_resourceId)
getIncome(Resource c_resourceId)
getStorage(Resource c_resourceId)
getUsage(Resource c_resourceId)

for a particular resource? I can guess on a couple....but...some clarification would be awesome.

Another stupid question...how many resource types ARE there in (for example) BA? Just metal and energy?

What is a 'feature'? (com.springrts.ai.oo.Feature)? Where can I get a list of feature IDs?

Is there any way my AI can determine how many different players there are? I can get a count of teams, but not the same thing.

Thanks in advance
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: More AI Interface Questions (maybe not java specific)

Post by Kloot »

"Current" tells you how much of resource R the AI has in storage.
"Income" tells you how much of resource R the AI is producing.
"Storage" tells you how much storage capacity for resource R the AI has.
"Usage" tells you how much of resource R the AI is spending.

There are two concrete engine resource types (metal, energy) that AI's know about; however, many non-*A games define their own types with Lua code outside of the engine's view.

A feature is any static game object (trees, rocks, wrecks).

The player count is inaccessible.
casperjeff
Posts: 51
Joined: 14 Aug 2008, 21:54

Re: More AI Interface Questions (maybe not java specific)

Post by casperjeff »

thanks!!

""Income" tells you how much of resource R the team is producing." per frame? per second? per what?

"The player count is inaccessible."
:(
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: More AI Interface Questions (maybe not java specific)

Post by hoijui »

why you need to know about hte players?

You can fetch a list of resources of a mod. even doh this currently only works for the engine ones, you should rely on this.. so you do not have to know about what reosurces there are.. as you can dynamicaly fetch the list ...
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: More AI Interface Questions (maybe not java specific)

Post by Kloot »

per frame? per second? per what?
Sorry, forgot to mention that. Both production and usage are measured per 32 frames.
casperjeff
Posts: 51
Joined: 14 Aug 2008, 21:54

Re: More AI Interface Questions (maybe not java specific)

Post by casperjeff »

"why you need to know about the players?"

I don't strictly NEED to know (some of my algorithms are based on how cramped the map will be...based on how many players)....

But does number of teams (which I CAN count) equal the number of starting commanders? If so, then I am good to go.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: More AI Interface Questions (maybe not java specific)

Post by Tobi »

casperjeff wrote:But does number of teams (which I CAN count) equal the number of starting commanders? If so, then I am good to go.
Yes.

Although maybe some mods change this using Lua.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: More AI Interface Questions (maybe not java specific)

Post by hoijui »

Kloot wrote:
per frame? per second? per what?
Sorry, forgot to mention that. Both production and usage are measured per 32 frames.
are you kidding? for real? will have to doccuemnt that.
initram
AI Developer
Posts: 15
Joined: 07 Sep 2009, 14:28

Re: More AI Interface Questions (maybe not java specific)

Post by initram »

does the AI not run in 30 FPS? why is it in 32 frames?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: More AI Interface Questions (maybe not java specific)

Post by Kloot »

No, Spring (and any loaded AI lib) does run at a base-rate of 30 simulation frames per second. However, the economic state of a team is backed up every 32 frames (during a "SlowUpdate" in engine parlance), and the state values for income and usage that AI's have read access to represent summations over the last team slow-update cycle. So, at any frame f that is not an integer multiple of 32, an AI is only able to obtain its cumulative income and usage from frame (int(f / 32) - 32) up until frame int(f / 32).
cranphin
Posts: 136
Joined: 13 Jun 2005, 16:37

Re: More AI Interface Questions (maybe not java specific)

Post by cranphin »

Hmm, would it be possible to make a value(s) like that available via the ai interface ? :)
In case someone decides to change it at some point and mess with ai's written based on the knowledge ? :)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: More AI Interface Questions (maybe not java specific)

Post by hoijui »

what about dividing the returned values by 32?
that would be a problem for current AIs, but as i have access to most of them, i could fix this in the same commit.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: More AI Interface Questions (maybe not java specific)

Post by AF »

You mean the interface would return the current resources generated per frame rather than per slow update?

hmmm, that would need a few algorithms to be slightly re-engineered but would result in minor simplification.

Nonetheless the 32 frames fact is signicant and should not be ignored. Dividing by 32 and assuming that its per frame will only introduce a greater margin of error in certain algorithms, and we already have a large margin of error as it is due to non deterministic resource consumption.

Instead i would like an extra callout to find out how often resources are updated. For example a mod may define a new resource which comes in every 2 seconds in lua, I would find that data useful, and the 2 seconds value could be worked into algorithms.
cranphin
Posts: 136
Joined: 13 Jun 2005, 16:37

Re: More AI Interface Questions (maybe not java specific)

Post by cranphin »

What AF said :D
Sorta :)

It's not just the size of the value, it's the fact that the value is updated each 32'th frame (right ??).
So I want to get the value jsut after it's updated, or my info is old :)
So I want to know the 'keyframes' when this value is updated :)

Hmm, or mayby make the value update an event ? :D

There is something to be said for normalized values also tho :)
Post Reply

Return to “AI”