Shard 0.4/dev - Page 9

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

Post by AF » 12 Jul 2010, 23:27

It was tested here and I got no issues before release, and was retested again to make sure it ran with forebodings changes to evorts

Error message in the log suggests that the version naming containing a space is not allowed, although I have no idea why this does not cause issues here, Ill reupload in an hour or two, until then quick fix is to rename the folder so the 0.29 Spikey becomes 0.29_Spikey and then change the version tag in AIInfo.lua

Really though this should be changed as it's fugally to have to use underscores, and no lobby should have to do a search and replace, afterall what happens if I have to put in a valid _?

( reuploaded with renamed folder )
0 x

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

Re: Shard

Post by Forboding Angel » 15 Jul 2010, 17:41

Ok, I'm finally able to test stuff again (had carpet layers here for the past several days).

I'm getting a lot of CPU spikes from spikey. I'm not sure why, but it is very often and it happens from the very start of the game.

The cpu spikes are causing what feels like lag in the game, and a definite stuttering.
0 x

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

Re: Shard

Post by AF » 15 Jul 2010, 18:57

Its not that Spikey has gotten laggier, its that the average idle cpu usage has gone down, making the spikes more visible.

Think of it as a Mount Everest in a sea of mountain chains. What I've done is the equivalent of flattening the mountain chains, resulting in nice plains, but it makes the Mount Everest stick out
0 x

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

Re: Shard

Post by Forboding Angel » 15 Jul 2010, 22:29

AF, these spikes are hitting up in the 67% range. It's enough so that the game literally pauses/stutters for a moment. None of the past versions did that.
0 x

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

Re: Shard

Post by AF » 15 Jul 2010, 22:35

No changes have been made that would cause larger spikes to occur, other than perhaps, larger numbers of units.

What you are seeing is likely a result of Shards configuration allowing for more builders, building more things, with more attack units, a natural consequence of an improved economy.

Otherwise I simply do not have enough information to do anything more than speculate.
0 x

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

Re: Shard

Post by Forboding Angel » 18 Jul 2010, 09:50

AF wrote:Otherwise I simply do not have enough information to do anything more than speculate.
I can't give you more information AF, It stutters, randomly and often, and it's really really bad. You could gain more information by playing it and testing it for yourself.

Perhaps you should play a 1v1 with spikey and experience it for yourself. I got genuinely pissed off tonight while trying to play. Missing clicks, extremely choppy game and this was just in a 1v1. What makes me even more pissed off is the fact that shard spikey plays evo better than it ever has, but these 1 second pauses are completely unbearable.
0 x

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

Re: Shard

Post by AF » 18 Jul 2010, 20:04

I did mention it to you that in my own test plays I had experienced spikes but that they were no greater than existing spikes they were just more observable because all the overhead of a debug build was gone.

I just don't have time right now to write in timers and figure out what is the cause, so without any further information, I cant do much about it until my other responsibilities are done with and I can sit down and start a proper analysis.

Eitherway Shard is just as spikey as the previous working build, if not less, its just more obvious now.
0 x

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

Re: Shard

Post by AF » 18 Jul 2010, 21:41

I've started adding timers, not much yet, there's an AI option being added for them, when things take longer than a certain time it'll display the timings of main functions.

I need to do more work though to put in a proper benchmarking setup, I got other work to do
0 x

slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: Shard

Post by slogic » 19 Jul 2010, 10:55

Looked into source code. Looks like Shard does not support "unit given" and "unit captured" events. I was surprised that the hole game logic is moved into Lua scripts :) Also check your map "aliveUnits" in CppTestAI.cpp. It is always enlarging. You could remove items in "unit destroyed" event.

PS. I could not compile it. It requires external "swig" to be launched. Is it really required?

Also please update the first post with link to the source code and AI Wrapper. It is hard to find everything quickly.
0 x

User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

Re: Shard

Post by PTSnoop » 19 Jul 2010, 14:37

Still optimistically trying to compile on Ubuntu; I'm getting

CMake Error at CMakeLists.txt:11 (ConfigureNativeSkirmishAI):
Unknown CMake command "ConfigureNativeSkirmishAI".

...
-- Configuring incomplete, errors occurred!

That's with both 0.29Spikey and the GitHub version from July 19th 1:30pm. Do I need some sort of dependency thing?
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui » 19 Jul 2010, 15:06

you have to configure and compile spring, you cant just configure and compile Shard.
0 x

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

Re: Shard

Post by AF » 19 Jul 2010, 15:16

There are some optimisations in github atm that should prove effective to anybody with the spikes being too much of an issue.

I also kept the map enlarging because I envisaged that you could keep a unit object after the units death as a record the unit existed at some point, something to refer to in hindsight, even if it was flagged as dead. I forgot about it though..
0 x

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

Re: Shard

Post by Forboding Angel » 19 Jul 2010, 23:59

Yeah, AF was watching evo games last night with me and others playing vs shard and it seems that AF got the spikes under control. There are still a few here and there, but from what I can tell, they are infrequent.
0 x

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

Re: Shard

Post by AF » 20 Jul 2010, 15:36

As a note for new AI deva, building placement or closestbuildsite API calls are expensive, and totally unnecessary for factories.

Using the type variable in a unitef object, if it is equal to the string "factory", you can use the units position as the location of the build order rather than running fancy algorithms.

As well as this, I also introduced a basic load balancing heuristic for construction, in that inky one unit can progress to the next task each frame, although a unit will only wait 15 frames before giving up and doing it regardless, which helps smooth out things a little.

Those of you who know git, can get the lua files and copy them over your shard install to get the updates, although the factory optimization is in the C++ component, and will be available with v0.3
0 x

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

Re: Shard

Post by AF » 29 Jul 2010, 22:51

Making a basic new behaviour in Shard

Behaviours are assigned to units, and implement basic logic. For example, the Taskqueuebehaviour.lua file contains a behaviour that implements taskqueues, and the attackerbehaviour.lua file contains a behaviour called AttackerBehaviour that implements attacking, etc. Everything is named to be as obvious as possible.

To assign a behaviour to a unit, you use the behaviours.lua file. Here is the CA version of this file:

Code: Select all

require "taskqueues"
require "taskqueuebehaviour"
require "attackerbehaviour"

behaviours = {
	armcom = {
		TaskQueueBehaviour,
	},
}

function defaultBehaviours(unit)
	b = {}
	u = unit:Internal()
	if u:CanBuild() then
		table.insert(b,TaskQueueBehaviour)
	else
		if IsAttacker(unit) then
			table.insert(b,AttackerBehaviour)
		end
	end
	return b
end
Breaking it down, we first include the files containing the behaviours, so that lua knows about them:

Code: Select all

require "taskqueues"
require "taskqueuebehaviour"
require "attackerbehaviour"
so taskqueues.lua and taskqueuebehaviour.lua etc get loaded

Then, we define the behaviours table. Shard uses this table to look up what behaviours to assign to what unit. Inside the table is a list of units, and each unit has a list of behaviours

Code: Select all

behaviours = {
	armcom = {
		TaskQueueBehaviour,
	},
}
So here, the arm commander ( internal engine name being armcom ), is given the taskqueuebehaviour.

If we had a behaviour called the RandomBannanaBehaviour, we could assign it to the armcom unit type, like this:

Code: Select all

behaviours = {
	armcom = {
		TaskQueueBehaviour,
		RandomBannanaBehaviour,
	},
}
and we could assign it to corcom, like this:

Code: Select all

behaviours = {
	armcom = {
		TaskQueueBehaviour,
		RandomBannanaBehaviour,
	},
	corcom = {
		RandomBannanaBehaviour,
	},
}
If Shard cannot find an entry in the table, it will call the defaultBehaviours function to decide what behaviours ( if any) to give the unit. Here is the default implementation.

Code: Select all

function defaultBehaviours(unit)
	b = {}
	u = unit:Internal()
	if u:CanBuild() then
		table.insert(b,TaskQueueBehaviour)
	else
		if IsAttacker(unit) then
			table.insert(b,AttackerBehaviour)
		end
	end
	return b
end
You may wish to rewrite or override this for your game.

Creating the new behaviour

Create a new file named HelloworldBehaviour.lua, and inside it, put this:

Code: Select all

HelloworldBehaviour = class(Behaviour)

function HelloworldBehaviour:Init()
	game:SendToConsole("Hello World!")
end
The first line says that there is a behaviour called HelloworldBehaviour. This means you also get a default implementation, so that you only write the bits you want to. We want to implement the Init method, so we can say hello world. You can see the other callouts that you can use in behaviour.lua or by seeing whats inside other behaviours.

And there we have a brand new behaviour! ^_^ To assign this behaviour to a unit, we need to make 2 modifications. So, to assign the helloworld behaviour to a peewee, we would change our tasklist as follows:

Code: Select all

require "taskqueues"
require "taskqueuebehaviour"
require "attackerbehaviour"
require "HelloworldBehaviour"

behaviours = {
	armcom = {
		TaskQueueBehaviour,
	},
	armpw = {
		HelloworldBehaviour,
	},
}

function defaultBehaviours(unit)
	b = {}
	u = unit:Internal()
	if u:CanBuild() then
		table.insert(b,TaskQueueBehaviour)
	else
		if IsAttacker(unit) then
			table.insert(b,AttackerBehaviour)
		end
	end
	return b
end
Here all we've done is add the line:

Code: Select all

require "HelloworldBehaviour"
This is so that lua knows what we mean when we say HelloworldBehaviour, and then we assigned the behaviour to armpw, the internal name of the peewee.

Code: Select all

	armpw = {
		HelloworldBehaviour,
	},
Now, whenever a peewee is built, Shard will output the words "Hello World!" to the console!
0 x

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

Re: Shard

Post by Forboding Angel » 14 Aug 2010, 05:55

Need a new build of shard for the current spring release.
0 x

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

Re: Shard

Post by AF » 14 Aug 2010, 14:21

I haven't been at my home machine in 6 days, heck I don't know what I'm going to do about C++ API source with the new release
0 x

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

Re: Shard

Post by AF » 14 Aug 2010, 14:26

Regarding Linux


Springs build system uses springs lua files with shards code, not shards lua files, the changes necessary require modifications to the cmake build files, and I haven't the knowledge in this field to fix this else I would have sorted it by now.
0 x

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

Re: Shard

Post by AF » 14 Aug 2010, 19:25

I also dont have a copy of the latest C++ wrapper source, it wasnt put in the source release for latest spring, nor do I have the means to generate it myself via cmake.
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Shard

Post by hoijui » 15 Aug 2010, 08:40

here is the Cpp AI Wrapper generated sources for spring 0.82.3.0.

Shard CMake is very simple. it does not use the engine Lua implementation, only headers from the engine. The file has 7 lines of "code", one of which is:

Code: Select all

include_directories(BEFORE ${CMAKE_SOURCE_DIR}/rts/lib/lua/include)
hard to guess what that means, hm?

for real, you just do not want to waste time on trying to get it running on linux (which would probably require you testing on linux). solution is, to clearly state that, and to always ask for help/cooperation when someone asks for Shard on linux. that means, not hoping on me doing it, but asking everyone for help, that might be tempted enough.

.. same goes for the herewith supplied generated sources, btw.
Attachments
spring_0.82.3.0_Cpp_AIWrapper_src_generated.zip
(96.1 KiB) Downloaded 22 times
0 x

Post Reply

Return to “AI”

cron