Dropping a worker

Dropping a worker

Postby hwoarangmy » 04 Aug 2014, 19:04

Hello,

While fixing multiplayer, I have found that workers are pretty hard to handle. When I drop them, they do not do what I want. They go wandering or digging when I want them to claim tiles for example. I am willing to do a patch for this. Do you agree ?
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 08:29

Hi, :)

I don't mind at all since it would remove one of the things I wanted to do. ;) I'd even say that the behavior should be improved for any kind of creature.

As a first step, I wondered whether the creature action stack is emptied when you drop it. (I'm speaking for any kind of creature.) I guess this would already help if it is not done yet.
As a second step, may I suggest that when a creature is dropped, it checks the immediate neighbors tiles, making it do what you wanted to?

Best regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 09:29

Bertram {l Wrote}:As a first step, I wondered whether the creature action stack is emptied when you drop it.
The action stack is emptied when you pick a creature. So when you drop it, it is empty (only idle action).
https://github.com/OpenDungeons/OpenDun ... er.cpp#L86

Bertram {l Wrote}:I'd even say that the behavior should be improved for any kind of creature.
For the fighters, I think we need to make sure what we want. Do we want a different behaviour when a fighter is dropped in front of ennemies or when he sees them alone ? Do that changes the action choice ? As the change is not heavy, I think we should wait until we have a proper fighting system and see if the system has to be improved or if it is ok as it is.

BTW, here is the logic I used when dropping a worker. If the conditions are met, he will do (in this order) :
1 - If one of the 4 neighboor tiles is marked for digging, he will dig
2 - If the tile he is in is not claimed and one of the 4 neighboor tiles is claimed, he will claim his position tile
3 - If the tile he is in is claimed and one of the 4 neighboor tiles is not claimed, he will claim it
4 - If the tile he is in is claimed and there is a claimable wall, he will claim the wall

If none are met, he will start a standard choice.
After he starts an action, standard choice applies and he might stop doing what he is doing to go somewhere else like if he had decided alone.
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 09:51

thanks for the insight,

The current logic looks fine btw. Except the last statement that should be done only when left alone. I guess this is what you'd like to change?
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 11:14

Bertram {l Wrote}:Except the last statement that should be done only when left alone
Which statement ?

Bertram {l Wrote}:I guess this is what you'd like to change?
In fact, the reason is that I tried to use cannon trap to see if something was broken with my fix. So I tried to go ASAP to another player to set a trap. But it is really anoying when you drop a worker to claim tiles and he goes somewhere else to dig or to wander :)
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 11:39

Which statement ?

Oops, sorry that one:
After he starts an action, standard choice applies and he might stop doing what he is doing to go somewhere else like if he had decided alone.

Yeah, it's annoying to see him do something else in that case.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby Danimal » 05 Aug 2014, 12:32

Hi guys, i think most of it is good, except the last one:

After he starts an action, standard choice applies and he might stop doing what he is doing to go somewhere else like if he had decided alone.


Is there no way to make them stick with what they were doing? it is infuriating to put them to claim tiles, they claim only one and then go somewhere else to do whatever, if i want them tile claiming or wall claiming its because is needed, it could be fatal in a turf war where you want to grab land as soon as possible or cut heroes pass with reinforced walls.

Couldnt the same AI check done at release(dropping) be repeated when initial action is finished? if it doesnt return any near task again they will go into default mode.

Btw hwoarangmy, fucking sweet update :D
User avatar
Danimal
OD Moderator
 
Posts: 1407
Joined: 23 Nov 2010, 13:50

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 12:54

Couldnt the same AI check done at release(dropping) be repeated when initial action is finished? if it doesnt return any near task again they will go into default mode.

Seconded. :)
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 14:43

Danimal {l Wrote}:it is infuriating to put them to claim tiles, they claim only one and then go somewhere else to do whatever
I made this update because before I did it, when they got dropped, they usually went somewhere else before claiming even one tile :)

Danimal {l Wrote}:Is there no way to make them stick with what they were doing?
Of course there is :) But we have to decide how we handle it to make sure that they will continue to do the same task until the end of their (short) life. We have some choices :
1 - They do the task until they cannot do it anymore (ie if they claim walls, they will do it until they see no unclaimed wall and return to normal decision).
2 - We just reduce the probability that they switch task. If so, how much ? Until when ?
3 - We keep the same behaviour as actually. In that case, they might change task after claiming 1 tile (that's the behaviour with my current patch).

Danimal {l Wrote}:Btw hwoarangmy, fucking sweet update :D
Thanks :)
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Danimal » 05 Aug 2014, 14:54

I would prefer this one :
1 - They do the task until they cannot do it anymore (ie if they claim walls, they will do it until they see no unclaimed wall and return to normal decision).


What about this? it would be a more complete solution
Couldnt the same AI check done at release(dropping) be repeated when initial action is finished? if it doesnt return any near task again they will go into default mode.
User avatar
Danimal
OD Moderator
 
Posts: 1407
Joined: 23 Nov 2010, 13:50

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 15:18

Danimal {l Wrote}:Couldnt the same AI check done at release(dropping) be repeated when initial action is finished? if it doesnt return any near task again they will go into default mode
I don't think it is the wanted behaviour. If we do this, if you drop a worker in an unclaimed room, he will claim everything (which would be good), then, he will see unclaimed walls and start claiming them all (which is not what I would expect).

Let's wait for other people before deciding :)
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 15:31

I just realised I forgot 1 thing. Let's summarize :
1 - If one of the 4 neighboor tiles is marked for digging, he will dig
2 - If the tile he is in is not claimed and one of the 4 neighboor tiles is claimed, he will claim his position tile
3 - If the tile he is in is claimed and one of the 4 neighboor tiles is not claimed, he will claim it
4 - If the tile he is in is claimed and there is a claimable wall, he will claim the wall
5 - If the tile is a treasure room and he is carrying gold, he should drop it
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 15:37

IMHO, you're forgetting gold:
0 - If one tile next to him is gold, he'll start digging.

Nevermind. the rule 1. takes care of it. Maybe make the rule 1 prefer gold tiles first? Or is it too much?

also, something to not forget:
In standard choice:
- If the digger has got gold on him and isn't digging gold and not fleeing monsters, it should put the gold back.

This would fix for instance the case in the small single/multiplayer map where sometimes the workers don't put gold back right away and you can't start putting rooms before they reach the gold common borders.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby Danimal » 05 Aug 2014, 15:47

Do you think we will ever implement the gold bag dropping on monster death? just like DK had, sometimes the heroes were the best gold source
User avatar
Danimal
OD Moderator
 
Posts: 1407
Joined: 23 Nov 2010, 13:50

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 16:08

Danimal {l Wrote}:Do you think we will ever implement the gold bag dropping on monster death? just like DK had, sometimes the heroes were the best gold source
I think we should because that would open interesting levels with not much gold but with rich heroes to slay :)
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 16:09

Do you think we will ever implement the gold bag dropping on monster death? just like DK had, sometimes the heroes were the best gold source

Now you tell it, this is a must-do, IMHO. Creatures should even drop other things on death, like spells, gold, special bonus, but starting with gold is already something.

I've added that on the later milestone: https://github.com/OpenDungeons/OpenDungeons/issues/34
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby hwoarangmy » 05 Aug 2014, 22:21

The pull request with the new workers behaviour is done :
1 - If the tile he is in is treasury and he is carrying gold, he should deposit it
2 - if one of the 4 neighboor tiles is marked, he will dig
3 - if the the tile he is in is not claimed and one of the neigbboor tiles is claimed, he will claim
4 - if the the tile he is in is claimed and one of the neigbboor tiles is not claimed, he will claim
5 - If the tile he is in is claimed and one of the neigbboor tiles is a not claimed wall, he will claim

He will continue his task until he sees nothing to do.

PS : I've set deposit gold at first position because it is the behaviour I was expecting when I tried the fix :)
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Re: Dropping a worker

Postby Bertram » 05 Aug 2014, 22:33

Yep, working and merged. :) Thanks a lot!
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby Danimal » 05 Aug 2014, 22:37

This sure will make them a lot more eficient
User avatar
Danimal
OD Moderator
 
Posts: 1407
Joined: 23 Nov 2010, 13:50

Re: Dropping a worker

Postby Bertram » 06 Aug 2014, 07:40

Danimal {l Wrote}:This sure will make them a lot more eficient

Small graphical regressions apart, the workers are a lot more efficient now, indeed.

Thanks a lot hwoarangmy. :)
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby MCMic » 07 Aug 2014, 14:39

hwoarangmy {l Wrote}:2 - We just reduce the probability that they switch task. If so, how much ? Until when ?

IMO this is what you should do.

I feel like you are coding too much special cases (well I did not actually read the code I say that because of what is said here)

How I see this:
- You add a priority order in possible actions for a worker:
0 - drop gold
1 - dig gold
2 - dig
3 - claim tide
4 - claim wall

When deciding what to do, it looks which action is possible in a certain range, and choose the more pressing one.
It also prefer the current action over others (something like current action has +2 priority or such).

When picked/dropped, pile is emptied and maybe the range used for action search is shorter.
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Dropping a worker

Postby Bertram » 07 Aug 2014, 15:15

Hi there,

Some little corections on my own:

hwoarangmy {l Wrote}:2 - We just reduce the probability that they switch task. If so, how much ? Until when ?

MCmic {l Wrote}:When picked/dropped, pile is emptied and maybe the range used for action search is shorter.

IMHO, indeed, there are 2 kinds of behavior there. The standard one (when the worker was idling), the forced one, (when he was dropped near his new target).

I do sincerely think the code should reflect that as it will be much more straight-forward to do.

hwoarangmy has already coded the forced one (when dropped), and it is looking fine so far, so I won't elaborate more than necessary but he has described the worker action order in the forums and within the code. Just have a look: https://github.com/OpenDungeons/OpenDun ... e.cpp#L797

As for the standard behavior, the one when finishing a task, or when idling if you prefer, IMO:

- The chance to make a worker change unexpectedly from a task to another should be removed as it is hard to debug, and isn't what the player is expecting.
Later, we can always readd chances to make the worker go idle if it is tired or something, but this shouldn't be mixed now as the default behavior is still not reliable.

- In standard mode, the worker should always take the top most priority available action even when doing something else, as it is what the user will expect.
I.e.: If enemies come near-by, the worker will have to go in "battle mode", making it either flee or fight immediately, whatever the former action was.

- Here is the action priority list I have in mind for the standard mode, feel free to correct me: (but IMO it's quite the same than yours)
1. Fight (Look for enemies near-by)
2. Drop gold when full of gold.
3. Dig gold (Look for marked gold tiles. The nearest reachable first, the farther next.)
4. Drop whatever gold it has.
5. Dig (Look for marked tiles. The nearest reachable first, the farther next.)
6. Claim tile
7. Claim wall
8. Idle.

Again, the top most available action should be checked every turn or every few ones, in standard mode. This means a worker will stop claiming whenever some reachable tiles are marked to be dug. A worker will immediately start fighting/fleeing whatever it was doing before if enemies come, ...
What makes it hard to follow with those actions in the code atm, is the intermediate actions needed to make this work. I.e: The worker will have to "walk" before it can "dig", ...
Atm, the action related code is treating every actions at the same level (walk is an action as important as dig.). This means that workers can be stuck walking randomly for odd and edge cases AFAIK. Maybe some differentiation might later help with this? (I mean separate creature current action, from current objective? Thus treat objectives in a separate way than actions, making them shape actions, for instance?)

Also, in DK1, they added room detection support, where the AI detected when you add dug shapes corresponding to a fitting room. This is making the workers come around and claim tiles and walls in an optimized way, so you can start using your new room more quickly. IMHO, this can be left for later.

Regards,
Last edited by Bertram on 07 Aug 2014, 15:36, edited 1 time in total.
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby Akien » 07 Aug 2014, 15:35

Bertram {l Wrote}:- Here is the action priority list I have in mind for the standard mode, feel free to correct me: (but IMO it's quite the same than yours)
1. Fight (Look for enemies near-by)
2. Drop gold when full of gold.
3. Dig gold (Look for marked gold tiles. The nearest reachable first, the farther next.)
4. Drop whatever gold it has.
5. Dig (Look for marked tiles. The nearest reachable first, the farther next.)
6. Claim tile
7. Claim wall
8. Idle.

What would be the scope for the marked tiles searching? If I have a handful of workers (A) at one end of the map where I marked gold tiles, and some workers (B) at the other end of the map where I marked non-gold tiles, I would expect the A workers to dig gold and the B workers to dig, but if they were to prioritize gold digging over normal digging, I fear that might B workers might cross the whole map to dig some gold too.
Godot Engine project manager and maintainer.
Occasional FOSS gamedev: Lugaru, OpenDungeons, Jetpaca, Minilens.
User avatar
Akien
 
Posts: 737
Joined: 22 Feb 2014, 13:14

Re: Dropping a worker

Postby Bertram » 07 Aug 2014, 15:44

Hi Akien,

What would be the scope for the marked tiles searching? If I have a handful of workers (A) at one end of the map where I marked gold tiles, and some workers (B) at the other end of the map where I marked non-gold tiles, I would expect the A workers to dig gold and the B workers to dig, but if they were to prioritize gold digging over normal digging, I fear that might B workers might cross the whole map to dig some gold too.


Good point.
Maybe this then?

1. Fight (Look for enemies near-by)
2. Drop gold when full of gold.
-- Dig Short range
3. Dig near-by visible gold (Look for marked gold tiles. The nearest reachable first, the farther next.)
3'. Drop whatever gold it has.
3''. Dig near-by visible marked tile. (Look for marked tiles. The nearest reachable first, the farther next.)
-- Dig Long range
4. Dig remaining reachable marked gold.
4'. Drop whatever gold it has.
4''. Dig remaining reachable marked tile

5. Claim tile
6. Claim wall
7. Idle.

What do you think?
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: Dropping a worker

Postby hwoarangmy » 07 Aug 2014, 17:03

I fear that with this kind of logic, they will all go to gold. Then, they will all claim then...

In fact, I think I would expect them to work more or less where they are. And definitely not to run all at the same task at the same moment.

MCMic {l Wrote}:How I see this:
- You add a priority order in possible actions for a worker:
0 - drop gold
1 - dig gold
2 - dig
3 - claim tide
4 - claim wall


MCMic {l Wrote}:I feel like you are coding too much special cases (well I did not actually read the code I say that because of what is said here)
We have the same special cases ;) At first, I had just forced the action for 1 turn. But after what have been said on this thread, I changed. And to be honest, I think it is better that workers keep on what they are doing. When they were forced only 1 turn, they usually stop claiming as soon as there is a wall to dig. But because OD is a strategy game, actions done by the player have to have impact.
And currently, I can manage them naturally to make what I want them to do. For me, it is the most important point...
hwoarangmy
 
Posts: 567
Joined: 16 Apr 2014, 19:13

Who is online

Users browsing this forum: No registered users and 1 guest