Shard 0.4/dev - Page 22

Shard 0.4/dev

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

Moderators: hoijui, Moderators

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Forboding Angel »

Then why isn't it fixed in the sauce?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Because no fixed code was received. I assumed you had fixed it since you had done tests since then prior to your most recent report, so I expected you'd be sending me the fixed behaviours.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

There will be a v0.4 this Sunday (possibly monday). It will include all the changes of the test versions, a fixed version of the evo file, and a fix for a crash reported by abma.

If there are any other small changes needed or questions before them let it be known now as it will be unlikely that there will be another Shard release for spring v85 or v86 unless there are bugfixes, most likely a v87/88 thing. I'd like to formalise my releases better on a reasonable timescale of months rather than the days or weeks I always aspired to (but never achieved)
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Forboding Angel »

Thanks for that. Apparently you told me what to do to fix things, and I just didn't understand it. Sorry about that.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Not to worry, there was a function with 2 versions of it, so that you could pass data 2 different ways and it would handle both. It didn't work as expected for some people though so I separated one out into a new version with a new name, and your code needed to use the new name not the old one.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Here's a DLL I'll package the rest up tomorrow
Attachments
SkirmishAI.7z
(398.88 KiB) Downloaded 196 times
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

Few questions:
1) Is there a command that takes any commandID and makes a unit perform the respective action?

2) If i create a random number in a module i.e.
ai.xzy=math.random(1,10) i always get the same for all AIs but if i do so within taskques i get different ones. Why?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Can you clarify 2) further, I'm not quite sure what you mean, are you comparing Shard to other AIs? Or modules to task queues?

1) No, at the moment there isn't. Such an API would be spring specific and would have been very, very hard to justify in my thesis. It also forces me to write a generic command API, which is not a 5 minute job, and it would encourage things that break on releases. This is why the only commands I've added other than stock commands are jumpjets and morphing as their implementations are consistent and widespread. (That and for quite a while nobody asked for them)
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

In 2) i compare two shards. Basically i wrote a module that does expensive calculations once in while to store the results.
In order to avoid multiple (Shard)AIs doing these computations in one frame (causes stutter with multiple AIs doing them at once) i create a random number as an offset.
The problem is that this number is random but its the same for every AI so they still do all their updates in one frame.

In taskques i randomize an AIs playstile giving each one a different favourite factory etc. in this case every AI player gets random results independant fro other AIs
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Clearly the seed is the same, if all Shard instances seed in the same frame, and the value of the seed is only on the scale of seconds then they could all well have the same random numbers.

I'd suggest modifying whatever seed you use to be some function of the team/ally number.

It would be different in taskqueues because taskqueues aren't created and executed at the same time (as some units take longer to build than others, and some taskqueues are shorter than others).
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

ah i see, i guess to fix it i would add the teams number or so. How would i get it?


Also how exactly does the recruits table work? How would i get the position of a recruit by calling the respective funciton?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Recruits are just stored in a table, if I had to guess the order, FIFO, although as soon as recruits is equal to the number of attackers needed to form the next group, an attack group is launched, so the positioning is unlikely to be of consequence. I suppose you could cherry pick the best recruits in a custom attack handler.

Of note, when modules are added, their module name is used to add it as a variable of the ai table. so a module called radarhandler would be accessible by doing something like:

Code: Select all

ai.radarhandler:whateverfunctionofthatmodulesinstance()
I'd have to look up the code to give you something that would work verifiably
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

I need the position of each recruit because i place warning labels on positions i.e. "base is under attack at 2000,500" in order to divert idle recruits to defending locations.

How would i get an object out of the table that i can call ".GetPosition()" for?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

To get the recruits table:

Code: Select all

ai.attackhandler.recruits
A recruit in that table is an instance of the AttackBehaviour. Each object has an internal named unit which is the AI unit ( as defined in unit.lua )

So given a recruit 'r':

Code: Select all

id = r.unit.engineID
I would say though that ALL recruits would be idle. As soon as the number of recruits X is equal or greater than the threshold, it's assumed that all recruits will be sent off to attack the enemy. A recruit is no longer a recruit when it is sent off to attack. Units are removed from the list when this happens, and remain off the list until they are idle again.

So you don't need to determine which recruits are idle, all recruits are idle, if they weren't they wouldn't be in the list. If I had to pick a name, I'd say they would be attackers, recruits become attackers when sent off to attack. When an attacker is idle, it enlists as a recruit and repeats the process.

edit: On checking again

It is indeed correct, recruits are idle attackers. When the threshold is reached, the attack handler sends all the recruits, not half, not however many is needed, but every single one of them. Then the recruits table is emptied, as there are no longer idle attackers waiting.

So if the threshold for an attack is 9, and there are 12 recruits, 12, not 9, will be sent to attack.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

That was not the question, i know how the attackhandler works.
The thing is that the AI might need to take a few of the waiting units in order to defend itself (in some games this might be necessary...) and for that i want to check the distance each defender has from the attacked spot in order to only send the ones that can reach it in reasonable time.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Anarchid »

Is there any decent manual on how to teach Shard to do stuff in a mod with severely weird econ rules dependant on custom orders?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Erik wrote:That was not the question, i know how the attackhandler works.
The thing is that the AI might need to take a few of the waiting units in order to defend itself (in some games this might be necessary...) and for that i want to check the distance each defender has from the attacked spot in order to only send the ones that can reach it in reasonable time.
You should be able to garner everything you need from those posts, as I mentioned, to access the recruits table:

Code: Select all

ai.attackhandler.recruits
For each recruit in that table:

Code: Select all

AIunit = r.unit
Where AIunit is a unit object as defined in unit.lua
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Anarchid wrote:Is there any decent manual on how to teach Shard to do stuff in a mod with severely weird econ rules dependant on custom orders?
hmmm the problem here is your analogy is based on the other AIs, they are fixed and you teach them how to use something. Think of Shard as a skeleton, what you want is not to add the flesh. So you would create the behaviours and modules that do the work. You can make modified versions of what's already there in a subfolder (e.g. stuff in the evoRTS folder will be used instead of the AI folder when playing evorts, so evoRTS can override the default behaviour).

I can answer any questions you have if you want to PM me or ask here, and I really need to compile everything together into a more coherent document. The nearest I have is the original project report, but I never released it, and Shard has seen refactors since then.


For custom commands, at the moment you'll have to do them via a gadget, and send that gadget commands via the API, e.g. game:sendtocontent("hello mr gadget, I have a message for you")

----------------------

I'd ask from now on if possible that people maintaining their own Shard modifications e.g. the stuff in the AI folder that's game specific, create git repositories. That way I can us git submodules and you have full control to edit and update as you please. It also means I don't have to perpetually bug people for the latest versions of things.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Anarchid »

I can answer any questions you have if you want to PM me or ask here, and I really need to compile everything together into a more coherent document. The nearest I have is the original project report, but I never released it, and Shard has seen refactors since then.
I'll compile some of those somewhere today, probably then :P
I'd ask from now on if possible that people maintaining their own Shard modifications e.g. the stuff in the AI folder that's game specific, create git repositories. That way I can us git submodules and you have full control to edit and update as you please. It also means I don't have to perpetually bug people for the latest versions of things.
Alternatively... is there no way currently for Shard to be provided its configs somewhere inside the game archive itself or otherwise in VFS?

(think of it: map-specific, map-provided shard modules? :P )
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by AF »

Anarchid wrote:
I can answer any questions you have if you want to PM me or ask here, and I really need to compile everything together into a more coherent document. The nearest I have is the original project report, but I never released it, and Shard has seen refactors since then.
I'll compile some of those somewhere today, probably then :P
I'd ask from now on if possible that people maintaining their own Shard modifications e.g. the stuff in the AI folder that's game specific, create git repositories. That way I can us git submodules and you have full control to edit and update as you please. It also means I don't have to perpetually bug people for the latest versions of things.
Alternatively... is there no way currently for Shard to be provided its configs somewhere inside the game archive itself or otherwise in VFS?

(think of it: map-specific, map-provided shard modules? :P )
Or modules that are crippled making the map unplayable when a new Shard release with refactors is made? Or me having to release multiple versions of Shard?

History has taught us that once a map gains traction, subsequent versions of the map with fixes are only adopted if the original map becomes totally and utterly unplayable. e.g. Metal Heck vs Metal Heck v2. Most people had v1, despite horrible issues that forced v2, and people continue to play on v1 to this day.

The original reasoning was that I had zero documentation for the VFS APIs in the OO C++ AI API. That's why NTai supported reading from the VFS and Shard didn't.

Still, it's perfectly possible to load different code for different maps, you can query the map name in Shard, or you could ask a gadget via the API call I mentioned earlier (where your game may have a listed of maps categorised, or code to automatically figure it out, etc)
Post Reply

Return to “AI”