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: 89
Joined: 27 Jan 2014, 01:04

Make workers reclaim and assist with Shard

Post by TurBoss »

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
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Make workers reclaim and assist with Shard

Post by AF »

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/
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Make workers reclaim and assist with Shard

Post by AF »

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
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

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
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

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
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

Last edited by TurBoss on 09 Dec 2015, 00:26, edited 1 time in total.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Make workers reclaim and assist with Shard

Post by AF »

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
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

Ok I did it that way an worked thank you so much
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

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

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

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

ok i think i got it

I added it like I do whit workers :)
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

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

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

Re: Make workers reclaim and assist with Shard

Post by AF »

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?
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

I have checked for unit is nil here but i', getting the same error
https://github.com/JauriaStudios/Shard/ ... ur.lua#L31
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Make workers reclaim and assist with Shard

Post by AF »

Can you print out as much information you can? Including the team, ally team of both the unit, and of the player
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

Ok i figured it

I was calling UnitCreated instead of UnitBuilt

hehe thank you
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Make workers reclaim and assist with Shard

Post by AF »

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?
User avatar
TurBoss
Jauria RTS Developer
Posts: 89
Joined: 27 Jan 2014, 01:04

Re: Make workers reclaim and assist with Shard

Post by TurBoss »

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
Post Reply

Return to “AI”