Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 29

Author Topic: DFHack: quickfort | buildingplan | blueprint | blueprints/library  (Read 91707 times)

myk

  • Bay Watcher
    • View Profile

    Update: quickfort is now part of the official DFHack release!

    The docs are available on the DFHack docs server:
    This thread has also expanded from just quickfort development to support of the whole quickfort ecosystem:

    Original first post:
    I'm implementing quickfort inside of DFHack. Why would I do this? Well, a couple reasons:
    • The original Quickfort is unmaintained, and is based on python2, which is slowly disappearing from the internet's collective consciousness
    • DFHack can apply blueprints faster, can gracefully recover from errors, and can intelligently select building materials based on available items and player preferences
    • There is an opportunity to integrate with other DFHack functionality, like generating workshop orders to build the items required for a blueprint
    For those who are unfamiliar with quickfort/qfconvert, the idea is that you record the keys you want to play back in a spreadsheet. Quickfort moves the cursor to the position that corresponds to the cell in the spreadsheet and plays back the keystrokes. Quickfort runs in one of four modes: dig, build, place, and query. Dig digs, build builds, place places stockpiles, and query changes building/stockpile settings. The mode is determined by a marker in the upper-left cell of the spreadsheet. You can see an example of sheets in each of the four modes here.

    What about digfort and fortplan?

    Yeah, they work great, actually, but digfort only does dig mode and fortplan only handles build mode, and only the buildings that buildingplan supports (mostly furniture). I plan to build on what they already provide, but I'd really like to see support for all buildings and constructions, stockpiles, query mode, the full set.

    So what's your plan?

    I wrote a design doc, if you're into that sort of thing, but here's a quick rundown of what I have in mind:

    Spoiler: Script usage examples (click to show/hide)

    What are your thoughts? How many quickfort users do we have out there who would appreciate something like this? What other features would you like to see? What are the most annoying manual steps you have to take that could be automated by this project?

    Here are the milestones I'm using to track my progress:
    Done
    • Plan is approved by DFHack core devs (@lethosor)
    • Forum thread started for public discussions and progress reports (this one)
    • Blueprint plugin saves files to blueprints/ dir (PR#1607) -- quickfort will read blueprints from this same directory
    • Interface skeletons are implemented (PR#1609, PR#159)
    • Settings can be set (PR#163)
    • Blueprints can be listed (PR#164)
    • Blueprints can be tokenized (PR#165)
    • Dig-mode blueprints can be applied (PR#167)
    • Place-mode blueprints can be applied (PR#168)
    • Build-mode blueprints can be applied (PR#169)
    • Query-mode blueprints can be applied (PR#171)
    • Stockpile settings are initialized (PR#172)
    • Documentation (PR#1617)
    • Curated library of blueprint files is included with DFHack (PR#1625)
    • Xlsx dependencies are included in dfhack build/release (PR#1620)
    • Can read from xlsx files (PR#177)
    • Basic buildingplan integration (PR#1622, PR#184)
    • Orders can be generated from build-mode blueprints (PR#185)
    • Multi-blueprint files/sheets (PR#185)
    • Meta blueprints (PR#185)
    • Zone mode (PR#185)
    • GUI (PR#185)

    All done! I have lots of ideas of where to go from here, but I'd like to see the script get some real usage first so we can work out the bugs.
    « Last Edit: September 28, 2022, 08:49:38 am by myk »
    Logged

    clinodev

    • Bay Watcher
    • Embark Profile Enthusiast, Kitfox & reddit mod.
      • View Profile
    Re: DFHack script: quickfort
    « Reply #1 on: July 14, 2020, 10:12:36 pm »

    I'm really glad to see this project!

    As one of the /r/dwarffortress mods, I very regularly see and field questions about problems with quickfort, and while I've been recommending the current DFhack replacements, not everyone has had great luck with those either. I tried to copy and duplicate one of my own mutti-level structures recently (mining only,) with them, and it was a mess. Perhaps it was an operator error, or the components didn't go together the way I hoped; I'm not sure.

    I am hopeful a single command / single source solution could solve a lot of problems, and if it reads the many existing community blueprints, that would be excellent!
    Logged
    Team Bug Fix!

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #2 on: July 15, 2020, 08:39:13 am »

    Yes, compatibility with current blueprints is definitely a priority. I'd hate to lose all the great work that's already out there!

    I think the feature I'm looking forward to most in this project is materials control. I'm just so tired of forbidding bars of ash and charcoal every time I want to apply a build blueprint!

    I'm curious - what are the common problems people have with quickfort?
    « Last Edit: September 11, 2020, 09:20:16 pm by myk »
    Logged

    danaris

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #3 on: July 15, 2020, 09:47:42 am »

    Very glad to see you picking this up, after I had to leave it unfinished five years ago!

    I don't currently have time for much Dwarf Fortress in my life, but if I did, I would definitely still want this tool, and I'm happy that soon it will (hopefully!) be available to those who can benefit from it.
    Logged

    clinodev

    • Bay Watcher
    • Embark Profile Enthusiast, Kitfox & reddit mod.
      • View Profile
    Re: DFHack script: quickfort
    « Reply #4 on: July 17, 2020, 06:36:59 am »

    myk quickfort notes

    Awkwardly, we remove the sorts of posts you'd probably like to see, but I'll copy a recent representative one  I can still view.

    >Hey everyone, I got some good help on credit last time with an issue I had, so here we go again.

    >I'm trying out quickfort as it came with the starter pack I downloaded, and I'm finding that the digs are coming out weird. It seems to be doing fine, and then all of a sudden at around 75% or so it starts doing a bunch of weird stuff, then it says its done. I've attached images of this that show the issue very clearly, but I've tested it on a bunch of blueprints.

    >Thanks for the help

    >*should also point out that it tends to designate stuff that is outside of the original footprint that was designated with alt-v.

    >

    >

    >EDIT: I've done some testing, and I think that it might be relevant that it fails in the same way every time.


    This is pretty much my post 0.44.x experience as well. I had a similar experience recently trying to use the DFhack equivalent tools, unfortunately, but I haven't followed up.


    Logged
    Team Bug Fix!

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #5 on: July 17, 2020, 01:57:05 pm »

    Problems with rendering dig plans should certainly be solved. Quickfort applies blueprints by simulating keystrokes, which is not exactly foolproof. Keystrokes can get lost, and cursor positions can shift when the screen has to scroll and the mousequery plugin's edge scrolling feature is enabled.

    This particular problem, though, is probably already solved with DFHack's digfort, which applies dig blueprints via DFHack's internal APIs. I plan to absorb its functionality into the new quickfort script.
    Logged

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #6 on: July 18, 2020, 08:32:18 am »

    Ok, I wrote a first draft of the help text (which will appear in https://docs.dfhack.org/en/stable/docs/Scripts.html). I'd appreciate comments on whether everything is clear -- especially on whether it would be clear to someone who had never heard of quickfort before! The formatting and hyperlinks get lost when I paste it in the forums like this, but you can see the markup source at https://github.com/myk002/scripts/blob/quickfort_skeleton/quickfort.lua

    Quote
    quickfort
    Processes Quickfort-style blueprint files. This is a pre-release – not all features are implemented yet.

    Quickfort blueprints record what you want at each map coordinate in a spreadsheet, storing the keys in a spreadsheet cell that you would press to make something happen at that spot on the DF map. Quickfort runs in one of four modes: dig, build, place, or query. dig designates tiles for digging, build builds buildings and constructions, place places stockpiles, and query changes building or stockpile settings. The mode is determined by a marker in the upper-left cell of the spreadsheet (e.g.: #dig in cell A1).

    You can create these blueprints by hand or by using any spreadsheet application, saving them as .xlsx or .csv files. You can also build your plan “for real” in Dwarf Fortress, and then export your map using the DFHack blueprint plugin for later replay in a different fort. Blueprint files should go in the blueprints subfolder in the main DF folder.

    You can read more about how to create blueprint files in the blueprints/README.txt file, and there are ready-to-use examples of blueprints in each of the four modes in the blueprints/library folder.

    Usage:

    quickfort set [<key> <value>]
    Allows you to modify the active quickfort configuration. Just run quickfort set to show current settings. See the Configuration section below for available keys and values.

    quickfort list [-l]
    Lists blueprints in the blueprints folder. Blueprints are .csv files or sheets within .xlsx files that contain a #<mode> comment in the upper-left cell. By default, blueprints in the blueprints/library/ subfolder are not included. Specify -l to include library blueprints.

    quickfort <command> <list_num>
    Applies the blueprint with the number from the list command.

    quickfort <command> <filename> [-s <sheet_num>]
    Applies the blueprint from the named file. If it is an .xlsx file, the -s parameter is required to identify the sheet number (the first sheet is -s 1).

    <command> can be one of:

    run
    applies the blueprint at your current active cursor position.

    orders
    uses the manager interface to queue up orders for the specified build-mode blueprint.

    undo
    applies the inverse of the specified blueprint, depending on its type. Dig tiles are undesignated, buildings are canceled or removed (depending on their construction status), and stockpiles are removed. No effect for query blueprints.

    Configuration:

    The quickfort script reads its startup configuration from the dfhack-config/quickfort/quickfort.txt file, which you can customize. The following settings may be dynamically modified by the quickfort set command (note that settings changed with the quickfort set command will not change the configuration stored in the file):

    blueprints-dir (default: ‘blueprints’)
    Can be set to an absolute or relative path. If set to a relative path, resolves to a directory under the DF folder.

    force-marker-mode (default: ‘false’)
    Set to “true” or “false”. If true, will designate dig blueprints in marker mode. If false, only cells with dig codes prefixed with m will be designated in marker mode.

    interactive-build (default: ‘false’)
    Allows you to manually select building materials for each building/construction when running (or creating orders for) build blueprints. Materials in selection dialogs are ordered according to preferences in materials.txt (see below). If false, will only prompt for materials that have :labels. See original Quickfort documentation for details.

    There are also two other configuration files in the dfhack-config/quickfort folder: aliases.txt and materials.txt. aliases.txt defines keycode shortcuts for query blueprints, and materials.txt defines forbidden materials and material preferences for build blueprints. The formats for these files are described in the files themselves.
    « Last Edit: July 18, 2020, 10:52:09 am by myk »
    Logged

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #7 on: July 20, 2020, 06:18:54 pm »

    Skeleton PRs are up as PR#1609 and PR#159!
    Logged

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #8 on: July 24, 2020, 08:46:12 pm »

    I've completed a few milestones beyond what I've started PRs for -- I'm waiting for the current PRs to get reviewed and merged before I start more PRs (I don't want to overwhelm the dev team with review requests!). Specifically, I just finished implementing dig mode, and I could use some help with test material.

    For those of you who have made blueprints, could you send them to me? I'd like to make sure I've tested "real" blueprints and can handle all the variations there are in style and formatting.

    The DFHack quickfort plugin will have a few capabilities beyond digfort or the original quickfort. the new quickfort script:
    • is FAST (hundreds of thousands of tiles designated in a few seconds)
    • works correctly even if some blueprint tiles are outside the map area
    • handles hidden tiles appropriately
    • handles area specifications like d(10x5)
    • handles track carving, including overlapping/crossing track segments
    • differentiates between chopping trees, gathering plants, and digging walls so only the intended tiles are designated
    • gives you nifty statistics about what was done

    The new script depends on some library functionality in PR1609, but once that gets in, people who are interested in beta testing can try it out.
    Logged

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #9 on: July 29, 2020, 01:36:14 am »

    In order to keep the new quickfort separate from the release while it's under initial development, lethosor has created a separate branch that I'm merging into. We'll merge it into master once it's implemented enough/stable enough, but beta testers are welcome to snag it from that branch in the meantime!

    In other news, I've implemented place blueprints except for one last detail. The fun part about place blueprints was implementing a "flood fill" algorithm that figures out the boundaries of an arbitrarily-shaped stockpile.  Now you can have stockpiles of any shape, as long as it's connected horizontally or vertically to another stockpile tile, and as long as the whole thing fits within the Dwarf Fortress stockpile limit of 31x31 tiles. For example:
    Code: [Select]
    #place
     ,a, , , ,a,a
    a,a, , , , ,a
    a,a,a, , , ,a
    a,a,a,a,a,a,a
    would create a valid, though oddly shaped, animal stockpile.

    The last bit of place to implement is enabling the correct stockpile category based on the type of stockpile in the blueprint. The code for this is not straightforward, and it looks like I'll have to do some refactoring inside of the DFHack codebase to cleanly support it. I'll probably move on to build for now and come back to this part later.
    Logged

    Fleeting Frames

    • Bay Watcher
    • Spooky cart at distance
      • View Profile
    Re: DFHack script: quickfort
    « Reply #10 on: July 29, 2020, 06:13:53 am »

    Huh. Does that mean
    Code: [Select]
    #place
     ,a,w,w,w,a,a
    a,a,w,w,w,w,a
    a,a,a,w,w,w,a
    a,a,a,a,a,a,a
    Would also work?

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #11 on: July 29, 2020, 10:59:31 am »

    absolutely. that layout is similar to one of my test cases that I used to verify the algorithm. You can have circular stockpiles surrounded by other circular stockpiles, or stockpiles that have the same bounding box upper-left corner like this:
    Code: [Select]
    #place
    a,u,s,h
    u,u,s,h
    s,s,s,h
    h,h,h,h
    (which doesn't sound complicated but there's some technical complexity with it)
    « Last Edit: July 29, 2020, 11:33:24 am by myk »
    Logged

    lethosor

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #12 on: July 29, 2020, 12:46:49 pm »

    PTW. That flood-fill support sounds cool!
    Logged
    DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

    There was a typo in the siegers' campfire code. When the fires went out, so did the game.

    Fleeting Frames

    • Bay Watcher
    • Spooky cart at distance
      • View Profile
    Re: DFHack script: quickfort
    « Reply #13 on: July 29, 2020, 02:18:14 pm »

    Does it connect diagonally or only orthogonally?

    myk

    • Bay Watcher
      • View Profile
    Re: DFHack script: quickfort
    « Reply #14 on: July 29, 2020, 03:52:26 pm »

    Currently, just orthogonally, but there's no reason why I can't make it also connect diagonally if that's what map makers want. What would be "expected" by a novice mapmaker? should this be one stockpile or two?:
    Code: [Select]
    #place
    a,a, ,a
    a, ,a,a
    In either case, I plan to suport adding labels to the cells so a stockpile can be defined as disconnected patches. Like, if we do decide to keep the flood fill just checking orthogonal tiles, we could still define the above stockpile as a single pile like this:
    Code: [Select]
    #place
    a:onepile,a:onepile,         ,a:onepile
    a:onepile,         ,a:onepile,a:onepile
    or even do a disconnected one like this:
    Code: [Select]
    #place
    a:onepile, , , ,a:onepile
    a:onepile, , , ,a:onepile
    a:onepile, , , ,a:onepile
    But I'll get to that once I get basic functionality done for build and query
    Logged
    Pages: [1] 2 3 ... 29