Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Idea for "smarting up" the dwarves a bit  (Read 1689 times)

CharonX

  • Bay Watcher
    • View Profile
Idea for "smarting up" the dwarves a bit
« on: January 05, 2008, 12:40:00 pm »

One of the most annoying traits of dwarves is currently that they just love to "paint themselves into corners" while digging channels, and building or removing architecture. I've had the idea for a (admittingly) very crude way to smarten things up: Group the Jobs into "Clusters", then do something like topological sorting on them.

code:

#########   # Wall
#CCCCC+++   + Floor
#CC.CC+++   C Floor with Channeljob
#CCCCC###   . Open Space
#CCCCC++#
###+#####


First the algorithm groups all jobs (and groups of Jobs) within, say, 3 spaces together (needs finetuning).
Then it determines the "entrances" to the Cluster by checking if the adjacent squares have a path to the (nearest) meeting area (or the wagon location if none has been defined) without using floors that have jobdesignations of the current Cluster. Non-designated floors adjacent to entrances (and the Cluster) are marked connected without further checks (obvious).
code:

#########   # Wall
#CCCCCE++   + Floor
#CC.CCE++   C Floor with Channeljob
#CCCCC###   . Open Space
#CCCCC++#   E Entrance
###E#####


Then all jobdesignations are marked moving forward from the entrances, using breadth-first search, until all designations are marked by their depth.
code:

#########   # Wall
#44321E++   + Floor
#33.21E++   C Floor with Channeljob
#22221###   . Open Space
#21112++#   E Entrance
###E#####   1,2,3,4 "Depth" of the Jobdesignation


Pathobstructing Jobs (Channeling, Building Walls) in a Cluster may not be executed until all such jobs of a higher number are completed (i.e. no jobs with a higher number exist). This way dwarves should no longer be able to corner themselves.

The algorithm needs to be executed whenever designations are added (or removed) by the player in the vincinity of the Cluster, but should probably wait for 2 seconds of "stabilitly" or so, to avoid continous retriggering (and lag) if the player adds designations while the game is running.

What do ya think?

[ January 05, 2008: Message edited by: CharonX ]

Logged

Sergius

  • Bay Watcher
    • View Profile
Re: Idea for "smarting up" the dwarves a bit
« Reply #1 on: January 05, 2008, 02:06:00 pm »

I think you hit the wrong "slash" key.
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Idea for "smarting up" the dwarves a bit
« Reply #2 on: January 05, 2008, 02:43:00 pm »

Sounds like an idea.
Logged

CharonX

  • Bay Watcher
    • View Profile
Re: Idea for "smarting up" the dwarves a bit
« Reply #3 on: January 05, 2008, 04:06:00 pm »

quote:
Originally posted by Sergius:
<STRONG>I think you hit the wrong "slash" key.</STRONG>

Woops, sorry, fixed.

Logged

Fedor

  • Bay Watcher
    • View Profile
Re: Idea for "smarting up" the dwarves a bit
« Reply #4 on: January 05, 2008, 04:45:00 pm »

quote:
Originally posted by CharonX:
<STRONG>I've had the idea for a (admittingly) very crude way to smarten things up: Group the Jobs into "Clusters", then do something like topological sorting on them.

(snip)

What do ya think?</STRONG>


Haven't a clue how easy or difficult this would be to fit into DF's overall AI, or how robust it would be when confronted with weird layouts, but I can't see a reason why it wouldn't work under normal conditions and with even a little player cooperation.  Definitely worth consideration!
Logged
Fedor Andreev is a citizen of the Federated Endeavor. He is a member of the Wandering Minds.

puffs

  • Bay Watcher
    • View Profile
Re: Idea for "smarting up" the dwarves a bit
« Reply #5 on: January 05, 2008, 04:58:00 pm »

yay for recursion!

[ January 05, 2008: Message edited by: puffs ]

Logged