Shard 0.4/dev - Page 42

Shard 0.4/dev

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

Moderators: hoijui, Moderators

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 16:48

I've made some changes to the code that may provide a more useful infolog.txt output, and catch some unexpected situations

https://github.com/tomjn/Shard/tree/master/data/ai

If you can replace your Shard data folder with the files from that location? I also tweaked how that behaviour works, so it may also correct the issue

Another question, does JW spawn additional units 100 or so frames into the game? And can you check if Shard tried to build anything? It may actually be the first building or unit built that has the issue, rather than the starting unit
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10239
Joined: 24 Jan 2006, 21:12

Re: Shard 0.4/dev

Post by PicassoCT » 06 Mar 2017, 21:57

Eh.. yes and no. Alot of gaia units are spawned and killed.
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 22:06

hmmm, I don't expect that would cause issues, can you let me know if the updated changes resolve things at your end?
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10239
Joined: 24 Jan 2006, 21:12

Re: Shard 0.4/dev

Post by PicassoCT » 07 Mar 2017, 10:32

Near similar error - which is suspicious.

I placed the updated files in the following folder:
C:\Users\PicassoCT\Documents\My Games\Spring\engines\103.0\AI\Skirmish\Shard\dev\ai
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 07 Mar 2017, 13:45

Do you have the infolog.txt for the error?
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10239
Joined: 24 Jan 2006, 21:12

Re: Shard 0.4/dev

Post by PicassoCT » 09 Mar 2017, 11:55

No, im currently at a ritual human sacrifice. Ill post one, once the daemon has devoured the virgin.

http://paste.springfiles.com/view/41a5fe84

;)
0 x

User avatar
prandipadaro
Posts: 92
Joined: 19 Oct 2011, 22:38

Re: Shard 0.4/dev

Post by prandipadaro » 09 Mar 2017, 19:05

I have start a little project in order to test ShardLua interface inside the springtutorialgame.
check the https://github.com/pandaro/springtutorialgame.sdd repo and follow issues, give me help and feedback
0 x

User avatar
prandipadaro
Posts: 92
Joined: 19 Oct 2011, 22:38

Re: Shard 0.4/dev

Post by prandipadaro » 11 Mar 2017, 13:31

I start the implementation of ShardLua inside the springtutorialmod.sdd
- First i have update the shard data folder inside the engine at the last git version.
- Second i have added a folder called "STG" in .spring/games/springtutorialgame.sdd/LuaRules/Gadgets/ai/STG
- then i have copied Copy in attackers.lua, behaviours.lua, and taskqueues.lua inside /STG

But i cant see ShardLua listed in springlobby

This is cause i do not have the interface Lua (original one https://github.com/eronoobos/ShardSpringLua) i think.

What i gonna do now?
How can i add the shardLua interfaces bundled with shard? (data/ai/preload/spring_lua/)
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 11 Mar 2017, 17:43

I've never tried to get Shard running inside a game archive, I've never looked into how it would be done.

I will add though, that you don't need to create a subfolder to test that Shard runs. The subfolder system is there to override Shards files, if it's not there then Shard will run as a generic AI, which means it won't do very much at all. Most likely all that will happen is you'll see it spit out a message in infolog that announces it's running then nothing much else will happen
0 x

User avatar
prandipadaro
Posts: 92
Joined: 19 Oct 2011, 22:38

Re: Shard 0.4/dev

Post by prandipadaro » 11 Mar 2017, 18:26

So, if I want to test ShardLua with springtutorialgame I do not need to create files in the game, but in the shard folder!, sorry, my fail!
I ask you:
I want to test ShardLua interface on springtutorialgame, what are the actions that I have to fulfill?
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 11 Mar 2017, 18:56

Nooo I mean the whole subfolder to override Shard files for a game thing, you definitely need to put Shard inside the game.

So this folder:

https://github.com/tomjn/Shard/tree/master/data/ai

Is fine as is, you don't need to create another subfolder for each game, e.g. BA will still work without this folder:

https://github.com/tomjn/Shard/tree/master/data/ai/BA

But it won't do very much
I want to test ShardLua interface on springtutorialgame, what are the actions that I have to fulfill?
¯\_(ツ)_/¯ No idea, never done it, never looked into it. Look at a game that's already done it ( no idea which games have already done it ). Eronoobos will know more. I can provide little to no help here, I'm more likely to ask you questions about it
0 x

User avatar
prandipadaro
Posts: 92
Joined: 19 Oct 2011, 22:38

Re: Shard 0.4/dev

Post by prandipadaro » 11 Mar 2017, 21:06

this is funny.
I will use your ShardLua interface, cause is the one that will be maintained in the future, not the one of eronoobos.
So you don't know how to use?
i ask you only how to use the function of Shard/tree/master/data/ai/preload/spring_lua
no more.
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 11 Mar 2017, 23:21

That interface provides the means for Shard to use the Spring Gadget API, but it does something needs to load and create an instance of Shard, and pass events to it.

That part is missing.

I can infer a few things based on a read of Eronoobos' work, I can infer that this file is what SpringLobby needs to pick up Shard:

https://github.com/eronoobos/ShardSprin ... /LuaAI.lua

And that a fork of Shard is located at:

https://github.com/eronoobos/ShardSprin ... gadgets/ai

This file acts as a gadget, and is the LuaAI that gets loaded:

https://github.com/eronoobos/ShardSprin ... Loader.lua

The file appears to do all the things that `boot.lua` was designed to do, as well as some other things, including creating each Shard AI and passing it events:

https://github.com/eronoobos/ShardSprin ... r.lua#L130

I would hope that less of this is necessary with the official Shard AI due to the refactors that have taken place. The intended use is that an object is created, e.g.

Code: Select all

shardai = AI()
And then, on events, a unit is converted into the Shard API type of unit like this:

Code: Select all

shardunit = shardify_unit( unitID )
shardai:unitcreated( shardunit )
Similar functions are necessary to translate other data passing into Shard. The API layer mentioned previously already does this for the engine APIs.

Study AILoader.lua, it appears that some additional steps are necessary, such as tracking multiple Shards ( 1 for each instance/player ), as well as differentiating between UnitDestroyed or EnemyDestroyed based as the engine does not appear to do that for you
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 11 Mar 2017, 23:23

This file seems to implement a number of translation functions:

https://github.com/eronoobos/ShardSprin ... /shard.lua

Systematising this would be useful so that these aren't dangling functions in the global namespace
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10239
Joined: 24 Jan 2006, 21:12

Re: Shard 0.4/dev

Post by PicassoCT » 12 Mar 2017, 01:17

After one threat page - just to communicate the near same amount of information - one picture:
Image
Attachments
Expected-Folders-and-Files-.jpg
(495.44 KiB) Not downloaded yet
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 12 Mar 2017, 01:23

That is incorrect

For the Native Shard that comes bundled with spring,

If Shard is located at: spring/engines/103.0/AI/SKIRMISH/Shard/dev/AI

Then Shard will search for files here: spring/engines/103.0/AI/SKIRMISH/Shard/dev/AI

and here: spring/engines/103.0/AI/SKIRMISH/Shard/dev/AI/SHORTGAME

Where shortgame is the shortened internal name of the game. Shard doesn't use Springs file system, and has no concept of .sdd files, game folders etc. All it knows is its own folder. By folder I mean folder on the disk as the Operating system sees it, not as Spring sees it.

This is not the case for a LuaAI running Shard which is what Eronoobos built, and what Prandipadaro is working on.

Shard does not need the subfolder to run, but it is unlikely to do anything. You should not recieve any errors, the worst case scenario is that you see Shard announce itself in the infolog.txt then do nothing with the units it's given
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 12 May 2017, 04:05

Shard now has an AILoader.lua gadget, and should run as a LuaAI if you copy the files in the right place and put a LuaAI.lua in the archive root.

BA mutator containing Shard McShardFace attached as an example, you may encounter issues using it

Image
Attachments
mcshardface.sdz
(202.61 KiB) Downloaded 12 times
shard_paulson.PNG
(1.01 MiB) Not downloaded yet
2 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 08 Jan 2018, 14:43

Currently working on a new building placement algorithm at https://github.com/tomjn/Shard/pull/144

Currently it uses the game engines closestbuildsite in shard native, and when running as a gadget in a game it uses an algorithm taken I think from CRAIG that tests positions using expanding circles. This one does it in an outwards square spiral on a custom grid, and tries to do the iterations spread out over multiple game frames so as to not lag things out

Usage should be something like this:

Code: Select all

function onSuccess( job, pos )
	-- build something I guess
end
function onFail( job )
	-- nowhere to place it, do something else then?
end
local unittype = ...
local job = {
	start_position=[x=1,y=2,z=3],
	max_radius=1500,
	onSuccess=onSuccess,
	onFail=onFail,
	unittype=unittype,
	cleanup_on_unit_death=builderID
}
local success = ai.placementhandler.NewJob( job )
if success then
	-- the job has been schedule, do whatever else we need to do in parallel
	-- when a position has been found, it will call the callback function we passed it
	-- in the future a promise will be returned letting us define what happens
else
	-- there was something wrong with our job and the system rejected it
	-- the programmer should probably check all the values that went into the job were set and valid
end
For a working example, see the taskqueuebehaviour in the pull request
2 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 21 May 2018, 10:53

Placement algorithm had some updates, now has a debug widget too, and checks for spacing using a basic heuristic.

Now that it's working and can be seen visually, the timing mechanism needs implementing, but, it's not so bad as it is currently and since it's asynchronous the hardcoded iterations act as a cap on max cpu usage

Additionally, these changes aren't fully compatible with the native Shard implementation. Some minor modifications might fix that, but all the interesting Shard activity is happening in Evo/BA right now as Lua AIs, and running a C++ codebase is more work with no benefit for me
1 x

User avatar
prandipadaro
Posts: 92
Joined: 19 Oct 2011, 22:38

Re: Shard 0.4/dev

Post by prandipadaro » 22 May 2018, 07:42

thank you again AF
0 x

Post Reply

Return to “AI”