Make workers reclaim and assist with Shard

Make workers reclaim and assist with Shard

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

Moderators: hoijui, Moderators

Post Reply
User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Make workers reclaim and assist with Shard

Post by TurBoss » 05 Dec 2015, 19:59

Hi,

I have managed to make a pack of units and Shard throwed then into battle
but I cant figure how to assign workers ( reclaim and assists only )

the queue starts building infinite workers that doesn't receive any order

my game is quite "strange" compared to A, only metal as resource and can only be adquired by reclaiming or killing enemyes

but for the moment i want to make a pack of workers and sen them to search the map for features
and at some point make another pack of workers to assist the factory

thx
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 05 Dec 2015, 23:16

Those workers will need behaviours assigned to them. It's likely they got assigned the taskqueue behaviour, but without defining task queues that behaviour won't do anything useful. It doesn't sound like your game has base construction though so that behaviour is of no use to you.

Here's an area reclaiming behaviour from Evolution RTS https://github.com/EvolutionRTS/Evoluti ... aviour.lua a little modification should get it doing what you want. Similarly some modification of a copy could give you a repair behaviour

Here's one that builds a turret when the unit is under attack https://github.com/EvolutionRTS/Evoluti ... aviour.lua

For repairing, I'd suggest you grab all friendly units, and search for the closest unit where HP != Max HP and issue a repair command, the repair command takes another unit as a parameter

You'll need to assign these behaviours to your worker unit, this post should explain how to do that:

http://shard.tomjn.com/2010/07/29/adding-new-behaviors/

Here's some information regarding behaviours that may be useful:

http://shard.tomjn.com/2015/11/17/recla ... ehaviours/

Here's some information on how to reclaim things:

http://shard.tomjn.com/2011/09/27/searc ... -features/
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 05 Dec 2015, 23:19

One thought, you could add a behaviour that's assigned to whatever is building your workers, that makes it build workers, and counts workers. When it counts the workers and sees a certain threshold is reached, it can yield control.

This way your taskqueues can focus on stuff that aren't workers, and your worker count is as you desire. Just make sure you tell the behaviour to have a priority of 0 when you have enough workers, and a priority of 1000 or something silly high when you need to make workers. Make it trigger the behaviour election on unit Idle if it needs to take control so that it doesn't interrupt any existing orders
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 07 Dec 2015, 04:21

thx for the detailed info


I'm investigating :)

PS: when i compile Spring the compile proccess fails to get the evo config and also the spring buildbot seems to not grab it too
Mantised this
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 07 Dec 2015, 09:30

I managed to made workers reclaim the features i want but when they end reclaiming they don't search for more features

how I can do this?

thx
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 07 Dec 2015, 09:31

Last edited by TurBoss on 09 Dec 2015, 00:26, edited 1 time in total.
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 07 Dec 2015, 14:37

Your behaviour issues an area reclaim command when it's activated, but once that command has been performed, the unit becomes idle

Perhaps, there are no more features left within the radius of 200 you specified to find? I would move the area reclaim command into the update routine, and have UnitIdle and Activate turn on a flag indicating that the reclaiming needs to occur, then set the flag to false when the command is given.

Currently, an active behaviour that's chosen a second time has it's Activate function called the second time it's chosen. I'd prefer Shard didn't activate active behaviours as it seems counter intuitive, I will think about this
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 07 Dec 2015, 16:15

Ok I did it that way an worked thank you so much
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 11 Dec 2015, 02:37

AF wrote:you could add a behaviour that's assigned to whatever is building your workers
How i can do this? :)

thx
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 11 Dec 2015, 02:57

ok i think i got it

I added it like I do whit workers :)
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 12 Dec 2015, 09:57

I hit a strange problem

i made a file called utils.lua with a simple function that checks is a unit is on a table like attackers

seems to work on behaviours.lua but not in my unitcounterbehaviour.lua

https://github.com/JauriaStudios/Shard/ ... /utils.lua
http://paste.springfiles.com/view/8e82bf76

:\
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 12 Dec 2015, 16:48

I see it's iterating over a list of workers, which is a list of unit names, strings, you should check if unit is nil, is that the case?
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 12 Dec 2015, 17:06

I have checked for unit is nil here but i', getting the same error
https://github.com/JauriaStudios/Shard/ ... ur.lua#L31
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 12 Dec 2015, 19:45

Can you print out as much information you can? Including the team, ally team of both the unit, and of the player
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 12 Dec 2015, 21:35

Ok i figured it

I was calling UnitCreated instead of UnitBuilt

hehe thank you
0 x

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

Re: Make workers reclaim and assist with Shard

Post by AF » 13 Dec 2015, 02:11

Do you still have the information from the echos? I see you were outputting Shards team and ally team, did you get the unit team and ally team for a comparison?
0 x

User avatar
TurBoss
Jauria RTS Developer
Posts: 88
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss » 13 Dec 2015, 05:23

If I understand correctly

is this what you need?

Code: Select all

function UnitCounterBehaviour:UnitBuilt(unit)
	
	EchoDebug("Team ID: " .. game:GetTeamID())
	EchoDebug("Unit Team ID: " .. unit:Team())
end

http://paste.springfiles.com/view/ffbc92cd
0 x

Post Reply

Return to “AI”