Shard 0.4/dev - Page 41

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: 20667
Joined: 14 Sep 2004, 11:32

Re: Shard 0.4/dev

Post by AF » 22 Apr 2016, 12:22

I'm intending for `ai` to be reusable and for it to be passed to modules rather than called from the global namespace. I hadn't anticipated the game/map objects, but yes Shard as a Lua AI will be very stupid right now, most of the APIs are hardcoded to return false, at least until somebody gets around to hooking them up to the right Spring API.

It'd be great if the needed changes to the AI lua were made to the main Shard repo though so the same codebase worked across both native AI and lua AI
0 x

User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

Re: Shard 0.4/dev

Post by eronoobos » 22 Apr 2016, 16:46

AF wrote:most of the APIs are hardcoded to return false
I saw that. I was surprised even that much is there! I didn't know you had planned on it being run in a Spring Lua environment. I was working on filling in all those empty functions, when I realized the issue that they're globals, will all be the same for every AI instance.
AF wrote:It'd be great if the needed changes to the AI lua were made to the main Shard repo though so the same codebase worked across both native AI and lua AI
On one hand, I like the idea of just dropping a Shard config into a fully compatible Shard implementation as a Spring Lua AI. On the other, it feels deeply silly to write an AI with all these proxy functions when, as a gadget, it has direct access to everything it needs already.
0 x

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

Re: Shard 0.4/dev

Post by AF » 22 Apr 2016, 16:57

The intention was that you could run it in other engines, calling the APIs directly would mean abandoning the native AI interface as an option, which may be useful still for some things and some people due to the C++ parts

If you look in the GH issues there are some things that should make some of the work easier such as the AI object creation being moved to a boot.lua etc
0 x

User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

Re: Shard 0.4/dev

Post by eronoobos » 22 Apr 2016, 17:40

Ahh, it would've behooved me to look at the issues. Maybe the most helpful thing I could do is work on https://github.com/Tarendai/Shard/tree/ ... spring_lua ? Also, Shard will need something like https://github.com/eronoobos/ShardGoneN ... Loader.lua (which I adapted from raaar's MFAI) to work as a Lua AI. I'm not sure where such a gadget should be stored in the Shard repo.
0 x

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

Re: Shard 0.4/dev

Post by AF » 23 Apr 2016, 22:19

That would be the LuaAI equivalent of `boot.lua`, I would keep that in a separate repo and have it load and use files in a subfolder, a subfolder filled in by the Shard repos lua

Another suggestion would be if you can modify the `shard_include` file to handle the VFS apis? The function may need moving out of the file its in to a file in the API subfolders so that it can have multiple implementations, or at least a file that can be loaded prior to everything else
0 x

User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

Re: Shard 0.4/dev

Post by eronoobos » 24 Apr 2016, 12:40

AF wrote:if you can modify the `shard_include` file to handle the VFS apis?
Do you mean modify the shard_include function in https://github.com/Tarendai/Shard/blob/ ... ad/api.lua? Yes, I'll have it do what it does in my repo, but under some if conditions (if the Spring table exists). For it to work, however, anyone using it as a LuaAI will need to make sure the Shard files are in the right place in their game archive. Also I'll start making these changes to the Shard repo rather than in my own lalaland.
0 x

User avatar
eronoobos
Posts: 73
Joined: 27 Mar 2015, 20:25

Re: Shard 0.4/dev

Post by eronoobos » 27 Apr 2016, 12:08

I have Shard somewhat working as a LuaAI with my fork of Shard (https://github.com/eronoobos/Shard) + the AILoader gadget (https://github.com/eronoobos/ShardSpringLua) loaded into a copy of BA.

It handles multiple instances' calls to global ai, game, and map with terrible hax https://github.com/eronoobos/ShardSprin ... r.lua#L134

Haven't made a pull request because I'm working from the assumption of a boot.lua for non-Lua Shard. Therefore the changes to ai.lua would break things at the moment.

edit: one unexpected characteristic of the LuaAI implementation, it's faster
0 x

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

Re: Shard 0.4/dev

Post by AF » 02 Oct 2016, 02:33

An update.

At this moment in time Shard has been removed from Springs build system. This is due to a number of builds being broken due to a mistake by Forb, another by myself, and a breakdown in communications ( I was not notified that the Lua was broken in latest Spring builds, and was unaware until it reached a critical point ).

With that in mind I've made these adjustments:

- A Null API has been implemented. It makes no operations and can be ran in any terminal with the command

Code: Select all

lua boot.lua
. This means it's possible to bootstrap Shard for unit testing, and the very act is a basic integration test that verifies the main startup procedures work correctly.
- I've set up Travis CI to run the aforementioned test, and confirmed its results
- I've corrected the error breaking current Spring builds, it no longer occurs under v103 of the engine

That still leaves some issues. For one, with Shard removed there are no more automated builds of Shard via buildbot. It's proven to difficult to get a developer environment to do C++ work in, and since the Vagrant environment I started wasn't finished or maintained by those who knew how, I wasn't able to use that. A docker container would be better, but none has been created either. I'm uncertain as to how I will ensure a binary is available for v104, especially since content distribution is entirely via Rapid/prdownloader which does not support AIs

The pure lua version has come a long way, and I hope this leads to it prevailing as an option, allowing me to shed the C++ component, but the two don't have feature parity yet
0 x

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

Re: Shard 0.4/dev

Post by AF » 20 Jan 2017, 12:45

I'm considering a change to how commands are issued to units and event handling, namely using promises, you'd be able to write something like this:

Code: Select all


unit:attack( enemy ):next( function( result )
		-- attacking the enemy now
		return unit:idle()
	end,
	function( err )
		-- something went wrong, maybe the unit
		-- died/the command couldn't be issued etc
	end )
):next( function ( result )
		-- the unit is now idle
		var thing = .....
		return unit:build( thing )
	end,
	function( err )
		-- something went wrong!
	end
)
What do people think?
1 x

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

Re: Shard 0.4/dev

Post by PicassoCT » 03 Mar 2017, 20:52

Is there some shard elementary tutorial?
Just the basic files needed to include in your game to get shard going?
What folder do i need to create?
0 x

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

Re: Shard 0.4/dev

Post by AF » 03 Mar 2017, 23:57

There's https://shard.tomjn.com but for the most basic of steps:

- create a subfolder named after your games internal name, Shard will prefer these files over its own when loading
- Copy in attackers.lua, behaviours.lua, and taskqueues.lua then adjust them accordingly

If you want to use this as a Lua AI inside your game, you'll want to grab https://github.com/eronoobos/ShardSpringLua, although you can test it with the Shard that comes with the engine beforehand
0 x

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

Re: Shard 0.4/dev

Post by PicassoCT » 04 Mar 2017, 00:24

Sorry, where should i create this subfolder inside my gamefolder?
I did create a folder called Journeywar - to no effect.
Must this be addes seperatly to the spring Engine?
0 x

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

Re: Shard 0.4/dev

Post by AF » 04 Mar 2017, 00:46

it's a subfolder alongside the other game folders. Note that Shard has no concept of the VFS, can't read the VFS, and has a singular file system. If you're using native Shard, putting the subfolder in your game will make no difference.

If you used the LuaAI version though, that's different. You'd need to test to find out, but I would guess it could
0 x

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

Re: Shard 0.4/dev

Post by PicassoCT » 04 Mar 2017, 10:24

I created a folder /Journeywar$Version/ beside my game.
http://paste.springfiles.com/view/18c3f828
It seems files/methods are absent.
0 x

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

Re: Shard 0.4/dev

Post by prandipadaro » 04 Mar 2017, 11:59

0 x

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

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 02:14

Picasso, does this happen only when making your own changes, or for all usage of Shard? e.g. does XTA do this? Or a game Shard has never seen before with no modifications?

Also can you be more explicit about what you did? Full file paths so we know unambiguously which folder you're referring to, as well as what files are inside the folder and their contents so that it can be replicated. Right now the literal reproduction steps are to find the Journeywar game archive and run mkdir "Journeywar$Version". Did this happen prior to that folders creation?
0 x

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

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 02:26

Also, what does Journeywar do at the beginning of a game? Does it swap out or create units? Morph them etc? Anything that messes with the assumption that at the start of the game you get starting units, and they don't change in weird and unexpected ways?
0 x

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

Re: Shard 0.4/dev

Post by PicassoCT » 06 Mar 2017, 12:56

The same problem occurs if i start nota 1.9.

The folder i created, resides beside the games folder.
C:\Users\PicassoCT\Documents\My Games\Spring\games\Journeywar$Version

PS: Yes my game does some strange shennanigans in late games, with units fransforming etc. But the start units are actually very similar in behaviour then nota.
0 x

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

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 16:18

hmmm, that won't work, Shard looks for a subfolder, it doesn't search your games folder. Remember, the Shard does not use the Virtual Spring Filesystem, it's a self contained system in a single folder and does not use Spring to load files.

The infolog suggests Shard is located at:

...ine\103.0\AI\Skirmish\Shard\dev\

So Shard will try to load:

ine\103.0\AI\Skirmish\Shard\dev\ai\bootbehaviour.lua

but if this file exists, it will load that instead:

ine\103.0\AI\Skirmish\Shard\dev\ai\Journeywar$Version\bootbehaviour.lua
0 x

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

Re: Shard 0.4/dev

Post by AF » 06 Mar 2017, 16:26

Also, I'm unfamiliar with NOTA's startup sequence, can you describe the process, assuming zero knowledge or assumptions, and without referring to other games?

The issue in question is that each unit is given a behaviour that controls its initial actions that runs once. There's a check to test if the unit is capable of moving or not, but this is failing for an unknown reason. I need to know that the basic assumptions still hold, and games have a habit of messing with these assumptions ( then stating everything is normal, albeit normai for them ).

Shard assumes a standard starting sequence, that of a single starting unit ( e.g. a commander ), that the user can control, that is at no point swapped out, and involves no temporary units, or units that change in some way in the first 100 frames
0 x

Post Reply

Return to “AI”