Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [39f] Digging path finding/A* bug  (Read 716 times)

datta_sid

  • Escaped Lunatic
    • View Profile
[39f] Digging path finding/A* bug
« on: August 11, 2008, 07:30:49 pm »

I was watching the dwarves dig and it seemed to me there was a bug.

The dwarf would choose a tile to dig. Sometimes the chosen tile would be adjacent to them, in which case they dont need to move. However, if there is another position from which they can dig that tile, they will try to move there. I think it is a path finding bug. He would try to find a path to the tile, but the current tile would be reported occupied, since he himself is standing on it. Hence the system finds another spot to stand on to dig that tile, which may involve a long walk.

Can the digging code please be simplified so that a dwarf digs all neighboring designated tiles before trying to move from its current position ?
1. This makes the code faster, avoiding many A* calls.
2. This opens up areas gradually in blocks rather than veins.

Thanks
-Sid
Logged

acidd_uk

  • Bay Watcher
    • View Profile
Re: [39f] Digging path finding/A* bug
« Reply #1 on: August 11, 2008, 07:43:46 pm »

+1 Yeah I've noticed this, but I think occasionally they do use the same square, so maybe not quite as simple. Either way, they should really check if they can go from the same square, sometimes they do go an awfully long way round...
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: [39f] Digging path finding/A* bug
« Reply #2 on: August 11, 2008, 08:01:55 pm »

Has to do with the side priority they dig from.  W > E > N > S (same applies to diagonals, just add).

But yes, it would cut down on calls.
Logged

Christes

  • Bay Watcher
    • View Profile
Re: [39f] Digging path finding/A* bug
« Reply #3 on: August 11, 2008, 08:06:40 pm »

Not to mention frustration and mining time.
Logged

datta_sid

  • Escaped Lunatic
    • View Profile
Re: [39f] Digging path finding/A* bug
« Reply #4 on: August 11, 2008, 09:07:59 pm »

I think "side priority" comes from the way this is coded. I bet W E N S were numbered 0 1 2 3 in the code  :P.
I guess, with some extra work, dwarves can choose closest tile to dig from..... but might be expensive to decide that.....
Preferring to stand in the same spot hopefully is a cheap, easy and effective way to dig!
Logged

mithra

  • Bay Watcher
    • View Profile
Re: [39f] Digging path finding/A* bug
« Reply #5 on: August 11, 2008, 09:31:20 pm »

I think "side priority" comes from the way this is coded. I bet W E N S were numbered 0 1 2 3 in the code  :P.
I guess, with some extra work, dwarves can choose closest tile to dig from..... but might be expensive to decide that.....
Preferring to stand in the same spot hopefully is a cheap, easy and effective way to dig!

I think there is a bit of "closest tile" choosing that goes on, along with the side issue. The problem I've seen is that path to the "closest" tile isn't taken into account. So that tile may be on another z-level, or on the other side of a wall that requires a long trip to get to. It's the same problem with raw material selection.
Logged