Shard 0.4/dev - Page 26

Shard 0.4/dev

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

Moderators: hoijui, Moderators

User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

Is the builder immobile by a chance? With default Shard spothandler.lua immobile builders might get stuck trying to build extractors out of their build range. Mobile units should not have this problem.
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 »

Nope, I'm unaware of how the APIs for reading from the VFS work in the C++ API, I'm not sure if there are C++ Wrappers, there are definitely C APIs deep down for it
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 »

Nope, it is fully mobile.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

Is it possible to find out which team owns a unit?

Why I need that: game:GetFriendlies() returns not only my own units, but also those of allies, but I sometimes need only a list of my own units.
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 »

Use GetUnits instead
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 »

Shard on github should contain SWIG wrappers for std::vector<int> adn std::vector<float> later today.

Creation in lua would take the form:

Code: Select all

local floats = api.new_vectorFloat();
floats should behave as any other list of items in lua, I'm guessing table.insert should suffice

There's also vectorInt but I'm not using that anywhere at the moment.

I've also added IsBeingBuilt to the unit object.

You'll also find it useful to know that there si a Team method on the unit object returning the current units team as an integer.

Another note, It appears that due to a rather fantasticaly dumb mistake, the Repair method actually calls the Attack engine function. This is now fixed on github
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 »

A MaximumHeight and MinimumHeight have been added to the map object
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

api.lua does not mention unit:Team(), so I had no idea it exists (and it really does, I just tested).

Now I wonder what else might be there, but undocumented.
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 »

api/lua is being updated

Also added:
  • Unit engine objects now have a Wait command, taking 1 parameter ( a timeout value )
  • MaximumHeight and MinimumHeight methods have been added to the map object
  • A Unit move failed event has been added to the C++ component, though I need to add a function to the lua AI object to accept the new event
  • It seems my assumption that the Build command returned success/failure when called was not actually correct, I will need to investigate this further to catch a failure.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by Erik »

api.lua does not mention unit:Team(), so I had no idea it exists (and it really does, I just tested).
come to thread to ask question, see question answered, leave. Excellent service 8)

On a side note: why is my random not random in a selfmade module while it works in taskqueues?
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

Probably related to return value of Build() not being a success/failure: I've noticed a few cases of AI builders getting 'stuck': they stand there doing nothing, they don't have any active orders (selecting them in spectator view doesn't show anything), but TaskQueueBehaviour:UnitIdle() isn't called for them.

This seem to happen for example if a mobile builder is ordered to build a geo plant, but there are no geo spots on the map (not 100% sure on that). Immobile builders also get this problem, but with those any build order can cause that, not just geos.

I've implemented a sort of watchdog timer in taskqueuebehaviour.lua that forces the que to progress if current task is not finished in some amount of frames, but that's far from optimal as the unit is still wasting a lot of time before watchdog triggers (can't make it shorter because then long build projects will get abandoned). But I was able to get some statistics on the problem that way (which unit got stuck on which build order).

This problem can also be caused by behaviours sometimes not receiving UnitIdle() events for some reason (since I've noticed a very similar problem with units under control of my self-made behaviour unrelated to taskqueues), but I can't say for sure if that is the case.
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 »

Before I continue, let me note that this is the 20,000th post, and I am now the first person to reach this milestone on the forums. I expect Smoth will follow within the next month or two

Image

It seems in the API when the build order returns an unexpected value for whatever reason, an exception is thrown. Sometimes the build order is never issued and a false response is returned because the C+ portion tried to find a build location and none was found.

Anyways it's expected when the build order times out or fails that unit idle will be issued. The timeout is extremely high though.

Also if the unit gets stuck a movefailed event si fired by the engine, but this was never handled previously. The next version ( or current if you're grabbing it from buildbot ) does handle this event however, and by default uses it to then call UnitIdle.


As a sidenote, you could leave taskqueuebehaviour as is, and override it in the same way taskqueuebehaviour overrides behaviour, and behaviour overrides etc etc That way you need only implement the bits that are different, and the original taskqueuebehaviour is preserved as are your changes
Attachments
20000.PNG
(22.55 KiB) Downloaded 4 times
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

Here is what I'm working on: link. There are more changes to taskqueuebehaviour now than just watchdog. I've added 'cleanup' command which makes the unit reclaim stuff around, and probably a couple more things.

I'm pleased to report that Shard performs quite well at NOTA now, but there is still room for improvement.

I suspect builders can get 'extra' UnitIdle events somehow, although quite rarely. Sometimes (no more than about 5% of the time) freshly started building are abandoned and new ones started, just like the taskque was forced to progress by UnitIdle() right after starting new project. This is rare enough however to not affect the game much.
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 »

Is there any chance this might be caused by your idle timer? Are you using the buildbot builds?

Of note the engine also passes an event for when a player issues a command to an AI unit, I may add that in
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

I'm currently using the build from spring 91, not buildbot.

AI units seem to receive UnitIdle() after player command just fine, do you mean some special event for that case?
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 »

No I mean you mentioned you had a timer based system to try and catch idle units and give them orders by setting progress = true

You can try with the buildbot builds if you're too impatient to wait for v92 =p
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by yuritch »

Is it possible to set building facing in Shard? I haven't found how to do that, and it can be quite important to have factories face the right way (else units take more time to leave them which leads to lower output).
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 »

No but it can be arranged for a future update
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Shard 0.35RC2 & 0.31.1 Not So Ballsey

Post by abma »

created a wiki-page:

http://springrts.com/wiki/AI:Shard

it currently contains...uhm... nothing, but maybe that can be extended in the future. also i placed some links to the page... maybe we can add a small howto make an own ai/behaviour with it.

Imo writing some Lua-Code for Shard is currently the most efficient way to get a working ai because it needs no build environment / tools to compile. A plain text-editor is enough. :)
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 »

Thanks, I've tweaked the page a little bit, I should create a page for it and a README on tomjn.com

I should also probably tag the releases on github so that every Shard release doesn't show as 'dev' in the installer packages
Post Reply

Return to “AI”