Bay 12 Games Forum

Please login or register.

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

Author Topic: [LinDesignator] template-based automation utility (0.06b final version?)  (Read 10665 times)

shadow_slicer

  • Bay Watcher
    • View Profile

Introducing a template-based designation and construction automation tool: LinDesignator!

Current Version:
LinDesignator Version 0.06b

New in this version:
Fixed error with #dig and #place templates
Now outputs macros in the format of the built-in DF macro engine for DF 0.31 or greater. (For the old 40d* macros, use version 0.05)
Added simple GUI.

Note: This seems like it may be the last version I release. I don't plan on adding any more features currently (but if a bug crops up I will fix it). Also, I release the complete copyrights to LinDesignator to the public domain. You are free to use, modify, and redistribute as you like. (This software is provided as-is, with no claims of merchantability or fitness for purpose, etc.)

The goal of this program is to automate designation of digging, construction, stockpiles and other things for Dwarf Fortress running on Linux and Windows systems. It will eventually be compatible and hopefully comparable to the QuickForts tool for Windows.

Currently it supports a wide variety of operations, and should be able to run most QuickFort .csv templates without alteration.

Instructions:
This is still an early version so it may be difficult to run and bugs may exist.

To run the GUI either doubleclick on LinDesignatorGUI.py or run the command 'python LinDesignatorGUI.py'. Then select the source and destination files. Then press "Convert" to run the conversion. Then a message box will pop up to let you know if it succeeded or not. The GUI also takes command line parameters, so you can do something like 'python LinDesignatorGUI.py mymacro.csv mymacro.mak'.

To run the program, open a terminal and run the following command:
'python LinDesignator.py mymacro.csv > mymacro.mak'
where mymacro.csv is the template file to generate a macro for. This will generate a macro in the file 'mymacro.mak' which can be placed in the data/init/macro folder and then loaded using Ctrl-l. The macro will start at the position specified by the macro file (or 0,0 if not specified). The 2nd and 3rd command line parameters can be used to control the start position. Note that the cell in the first row of the first column is in position (0,0), not the (1,1) used by QuickForts.

Troubleshooting:
1. Your program said something like 'Bad QF command: ...for state=...'.
   a. Congratulations, you found an unhandled condition.
      If it said 'Bad QF command', then the stateful key translater doesn't know of a DwarfFortress command corresponding to the QuickFort Command for this menu. This could be (i) a bug in the template, (ii), an extra menu option that is not currently handled, or (iii) a bug in the state machine so it is processing the wrong menu. Note that (i) and (ii) are the most likely options. For case (i) fix the template!. For case (ii), you can find the appropriate DF command in interface.txt and add an entry for it in StatefullQFCommandTranslator.py under the menu specified by the error message. The format is 'QFcommand' : ('DFcommand','NextState'). Also post to the forum so that later versions can be fixed.

Differences with QuickFort:
The %wait% macro is not supported. Please use {wait} instead.
The '<' and '>' keys are not supported in templates.

New in this Version:


--0.06b--
Fixed error with #build and #place templates

--0.06--
Changed output to DF 0.31+ macros
Added GUI

--0.05--
Changed output to DF 40d* format macros

--0.03b--
Fixed bug where the last command in a group with no macros was ignored.

--0.03a--
Removed debugging code that redirected output to terminal instead of xte.

--0.03--
Stateful key translation (reduces the amount of ambiguous actions)
Compatibility with QuickFort 1.03 templates
Up and down levels using the #< and #> notation used by quickforts (also next template this level with #!)
Block grouping of designations, constructions and stockpiles
« Last Edit: July 29, 2010, 08:02:33 am by shadow_slicer »
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware
Re: [LinDesignator] template-based automation utility for Linux
« Reply #1 on: June 09, 2009, 03:32:51 pm »

One problem:
All I get is 403: Forbidden.

shadow_slicer

  • Bay Watcher
    • View Profile
Re: [LinDesignator] template-based automation utility for Linux
« Reply #2 on: June 09, 2009, 05:54:30 pm »

It should be fixed now. The web server was being weird. It seems it just didn't like that file name.
Logged

shadow_slicer

  • Bay Watcher
    • View Profile

I have also posted some standard templates at http://www.prism.gatech.edu/~bhamilton3/templates.zip
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile

It seems that you are doing it by sending key events to the game. Why are you doing it like that ? There are several tools that you can use to do it in memory, instantly. One of them being of course dwarf companion :)
Logged

shadow_slicer

  • Bay Watcher
    • View Profile

@bartavelle:
Yes, I am sending key events to the game. Yes, there are tools that make changes in memory to set designations and such. I don't like that approach. Messing around with another process's memory space doesn't seem like a very elegant method to me.

I started this project for a couple reasons: 1) I wanted a template based designator designed for Linux. 2) I saw the QuickFort post and thought that it was an interesting idea. 3) The problems associated with minimizing the number of keystrokes associated with a template based designator intrigued me -- I felt it was an interesting problem. I looked at the limitations of QuickFort, and wanted create a design that could go past it.

I write programs for fun, as a hobby. I like to learn new things (such as Python and Xlib), and the best way to learn a programming language or library is to use it. This project is probably the only python program I've written longer than 50 lines, so I learned a lot writing it.

I have LinDesignator 0.04 written, but haven't tested it with DF yet (it appears to work with the checkkeys test program for SDL, so it probably works). After that I'll probably look into adding a GUI (since I haven't written one in Python before), which will most likely mean I'll need to add threading for events and progress indicators...
Logged

Valdemar

  • Bay Watcher
    • View Profile

It seems that you are doing it by sending key events to the game. Why are you doing it like that ? There are several tools that you can use to do it in memory, instantly. One of them being of course dwarf companion :)

Well, Dwarf Companion's tile edit functionality has been subtly broken for a while now. I've tried updating my auto-designation macro 2.0, which works as you suggested using DC, but wasn't able to get it to work right.

As for the bug itself, I think I brought it up in the DC thread at one point. Every few lines that are designated (I think either the first or last line of each map block) gets designated to a different line within the map block, instead of where it's supposed to be. I assume one of the map block offsets is slightly off.

shadow_slicer

  • Bay Watcher
    • View Profile

Also I was too lazy to find the offsets for the Linux version of dwarf fortress. ::)

I think most of the memory editing tools available only target the windows version. Dwarf Companion relies on scanning the windows PE executable to find the offsets. These offsets are likely to be very different on the Linux version.
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile

Also I was too lazy to find the offsets for the Linux version of dwarf fortress. ::)

I think most of the memory editing tools available only target the windows version. Dwarf Companion relies on scanning the windows PE executable to find the offsets. These offsets are likely to be very different on the Linux version.

Indeed! DF is linux compatible but I forgot it meant it works with wine :)
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware

Code: [Select]
version       = v0.28.181.40d11
system        = linux
md5           = fb8ecac8a12af5d0d7b1707078985d0d
map_data      = 0x092FF7A0
x_count       = 0x092FF7B4
y_count       = 0x092FF7B8
z_count       = 0x092FF7BC
type          = 0x0052
designation   = 0x0254
occupancy     = 0x0654

These are the offsets for map extraction in 40d11 on linux.

shadow_slicer

  • Bay Watcher
    • View Profile

On my PC, I found map_data at 0x092FF79C. At least I think that's map data. It's the closest address that's a pointer into the heap. And it seems to point to an array of pointers that points to an array of pointers that pointers that points to an array of pointers that also point into the heap.

Unfortunately however, I haven't been able to find the designation section within the blocks at the end of the chain of pointers. All I'm seeing at 0x0254 is 0xFFFF and 0x0000... Neither of which are valid for designations. Also the final array of pointers is not as long as I'm expecting it to be.

I did find the cursor:
Code: [Select]
x_cursor  =  0x088073D4
y_cursor  =  0x088073D8
z_cursor  =  0x088073DC
.
Logged

peterix

  • Bay Watcher
    • View Profile
    • Dethware

This is awesome :) I couldn't find that one.

shadow_slicer

  • Bay Watcher
    • View Profile
Re: [LinDesignator] template-based automation utility (0.05 released!)
« Reply #12 on: September 07, 2009, 10:46:38 am »

Note that the newest version now supports built-in DF macros!
Logged

Erulisse

  • Bay Watcher
    • View Profile

The macros that this outputs don't seem to work with 0.31.12 The game coughs up an i/o error.
Logged

shadow_slicer

  • Bay Watcher
    • View Profile

Sorry, I haven't gotten around to updating the output. The macros it outputs are the old built-in macros of the 40d versions. For some reason they changed the macro file format with the new release. I'll try to update it sometime this week.
Logged
Pages: [1] 2