Shard 0.4/dev - Page 11

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: 14666
Joined: 17 Nov 2005, 02:43

Re: Shard

Post by Forboding Angel »

Awesome! Shard Hairy is back to it's usual happy, non-laggy, and kickass self! Thanks AF! :-)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui »

for a 5 year old, it would probably be even better, if you could write a sample config file for a mod that does not yet have one. it could consist of a single task list for one unit, containing all the other units, including (human-)name and description of the units:

_BA.lua (user has to remove the '_' for it to work):

Code: Select all

allUnits_list = {
   "corsolar", -- Solar - Produces energy
   "cormex", -- Metal Extractor - Produces metal
   ...
}
taskqueues = {
   corcom = allUnits_list, -- the unit will try to build the units from that list
}
i am sure this could be enhanced, eg. by having one list per side/faction instead. but in general, this allows to make a config file with just the template.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Technically there is already a sample in the form of the default taskqueues.lua which is being overridden. It contains a primitive BA taskqueue that serves as an example.

However I can see that it could nethertheless be improved by creating the overrides subfolder if it doesn't already exist and copying taskqueues.lua into it along with a readme.txt or howto.txt

I'll look into that for the .31 Ballsey release
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui »

the most important thing for me there, would be having the (full) list of units (shortName, name & description). i bet a lot of users would not know how to get this, if they are not the mod authors them selfs.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Im considering another update, no functional changes, just documentation changes. I've noticed some people have gone about things a slightly harder way based on the default examples, and some comments here and there, and slight redefinition of taskqueues.lua to guide people down the easier route would help.

That and one or two bits of sanity checking, as misspelt unit names can causes crashes when they're fed into the engine APIs, which can leave people getting puzzled when they're modifying Shards files and spring starts crashing.

So ,unless your developing with Shard, it would have no impact.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Notes on Tasks and Attackers that will be of use to anybody just starting with Shard:

Tasks are done from first entry to last, in order. If Shard cannot execute a task (eg no place to build it found), it will move on to the next task listed.

Attackers are also assigned an attackerbehaviour. You can do this manually via the behaviours table in behaviours.lua, or via the function underneath that table which is used if no definition for that unit type is found in the table. This is how most attackers are assigned in most peoples lua at the moment.

The default function hands a taskqueuebehaviour (the behaviour that implements task queues) to units if they are capable of building, else it will call IsAttacker to determine wether to hand it an attackerbehaviour or not. The IsAttacker function is simple, all it does is look at the attackers table and see if the unittype is listed, and returns true if it is, and false if it isnt. Refer to attackers.lua for an example, its just a basic list.

You can implement and write your own behaviours, and then tell shard in the behaviours table to use those rather than using the heuristic in the defaultbehaviour function ( I think that's the name of it ). Refer to the Evo RTS folder for an example of a custom behaviour.

Also of note.

The Taskqueues are defined in a lua table named 'taskqueues' in taskqueues.lua, and take the form of "unittype" = tableOfTasks, where the table of tasks is a lua array of strings, aka unit type names to build, starting in order from the beginning to the end.

If however the taskqueue behaviour finds a function not a table, it will call that function and expect a table in return. This way you can implement custom logic, and return different task queues each time, depending on who what or when it is called.

This is also true of the tasks themselves. Shard expects a string, e.g. "corsolar" for a core solar plant unit, however if it finds a function, it will call the function like above expecting a string as a return value.

I would suggest looking at evolutionRTS' shard support, and especially using the way the taskqueues.lua is formatted there, rather than how its formatted in conflict terra, as it is much more flexible and easier to read/understand.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7033
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

Shard 0.3 Hairy crash Spring 0.82.6.1 at frame 0.
Attachments
script.txt
The startscript used.
(1.22 KiB) Downloaded 122 times
infolog.txt
The infolog registered nothing.
(12.63 KiB) Downloaded 110 times
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

There is no crash information of any kind in that log, or any mention of any AI other than the filenames of KPAI =s Are you sure the script is correct? I dont see any version numbers in there
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7033
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

Code: Select all

	[AI0]
	{
		Name=Bot;
		ShortName=Shard;
		Team=0;
		Host=0;
	}
Or just try it.

I dont see any version numbers in there
Then maybe it is TASClient that is failing to write proper startscript?

Edit: No, SpringLobby write a bigger AI section, but it crashes all the same.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14666
Joined: 17 Nov 2005, 02:43

Re: Shard

Post by Forboding Angel »

Or perhaps spring version changed and shard's dll hasn't been updated? More likely than you think.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui »

the callback changed indeed. here are the generated sources of the Cpp Wrapper for 0.82.6(.1); see attachment.

for details of what changed, see:

Code: Select all

git diff 0.82.5.1...0.82.6.1 -- rts/ExternalAI/Interface/
Attachments
spring_0.82.6.1_AIWrapper_Cpp_srcGenerated.zip
(96.32 KiB) Downloaded 17 times
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7033
Joined: 16 Nov 2004, 13:08

Re: Shard

Post by zwzsg »

Forboding Angel wrote:Or perhaps spring version changed and shard's dll hasn't been updated? More likely than you think.
Exactly, and that's why I was reminding AF to fix his Shard.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

grr, in the past it was a simple error message from the engine saying the AI interface version was different. Crashing with no error log, message or warning is horrendous usability, nevermind graceful crashing.

If I'd had known this was going to be an issue I'd have set aside time this weekend to sort it out so nobody would be any the wiser, I need prior warning of these things!
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui »

Code: Select all

git diff 0.82.5.1...0.82.6.1 -- rts/ExternalAI/Interface/
this code can be adapted to work for feature releases too, i will not tell the secret of how to do it though... its Mr. E!
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

We shouldn't have to or need to, some AI developers are not familiar with git or even have it installed, and use the source releases on the downloads page. In the past we have always been told outright when the interface has changed enough to need us to recompile our AIs, and while the majority of openly available public AIs are being built on buildbot and bundled with, Shard is not alone, and there are other developers with various other intentions who are not active on these forums or in any community forum.

How are they to know that they need to rebuild when there are no error messages, stack traces, warnings, instructions, or notifications on the download?

Moreover how am I to know to rebuild if I'm on a machine where I cant freely browse the spring forums and load visual studio? If Im in work I can get into trouble by loading up the spring forums, release threads usually come in the form of emails to my phone, I dont even have visual studio on that machine. So given that in the past some releases have required no intervention to fix Shard, how do I know whether to go out and socialize, or go home and do a rebuild an re-release?
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

I've set aside time to put out a release tonight, just a minor rebuild for latest spring.

Thanks for posting the updated C++ Wrapper code Hoijui, perhaps we can have a sticky thread for it?
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Ive rebuilt and made one or two changes, performance should be higher, but please test it out, my drivers have made things awkward to test here and I havent got enough time left this evening to sort that out. Same blogpost, same download url.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

Has anybody else conducted further tests? I've had no feedback as of yet
User avatar
oksnoop2
Posts: 1207
Joined: 29 Aug 2009, 20:12

Re: Shard

Post by oksnoop2 »

I'm sorry AF, where is the link?
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: Shard

Post by AF »

First post in the thread as always. It's the same URL and blogpost as 0.3 hairy, just redownload.
Post Reply

Return to “AI”