Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Toady-safe manager plugin  (Read 1007 times)

Michael

  • Bay Watcher
    • View Profile
Toady-safe manager plugin
« on: April 16, 2011, 12:31:46 am »

One popular request is for an officially supported API to allow scripting or communication between DF and another program.  It was put on Eternal Suggestions almost a year ago and is sitting at 5 votes.  While that is not high in general, it's one vote more than the most popular of my own suggestions, and despite the fact that Toady One has more or less condemned the idea.

The problem is easy to understand.  There is pent-up demand for a game that is DF at the back end, but with a completely re-done user interface, and an API would allow creation of such a beast.  Toady fears this would allow someone to effectively become a co-author, stealing all new users who would otherwise grudgingly learn DF on it's own terms.

One simple way to allow some API benefit while minimizing the risk, is to limit the API in a simple way.  Plugin access to game data would normally be blocked, but the plugin could at any time prod DF into making the Manager do some office work.  This work would have no direct effect on the game, but once the job is finished, the game would be frozen and the plugin would be allowed most of the read and write access the player has.  Only once the plugin yields will time continue in the game.

Since an office needs to be built before the Manager can do anything, a player would need to learn basic skills in raw DF (how to create furniture and indoor space) before he can turn over control to the plugin of his choice.  And the time lag would make a full wrapper impractical even late game. 

But it should be good enough to allow for private implementations of "Standing Production Orders", the current #2 suggestion.
Logged

sockless

  • Bay Watcher
    • View Profile
Re: Toady-safe manager plugin
« Reply #1 on: April 16, 2011, 12:54:24 am »

The reason is about risk, but not for the reason you say.

Toady doesn't want to implement an API for this reason:
Since the game is in early alpha, he is bound to make changes to almost everything that's in the game right now. If he makes an API, the chances are that he's going to have to change it quite a bit in the future, this would break all current APIs, which would annoy a lot of people and many would just stick with the old version. It's already a problem and we don't even have an API, this problem is in the form of DFhack and co., these all broke at 31.13 when Toady changed compiler, Runesmith hasn't even been fixed yet.
Logged
Iv seen people who haven't had a redheaded person in their family for quite a while, and then out of nowhere two out of three of their children have red hair.
What color was the mailman's hair?

Michael

  • Bay Watcher
    • View Profile
Re: Toady-safe manager plugin
« Reply #2 on: April 16, 2011, 09:58:17 pm »

If he makes an API, the chances are that he's going to have to change it quite a bit in the future, this would break all current APIs, which would annoy a lot of people and many would just stick with the old version.

Only if the API is designed lazily.  An API that simply gave out the pointers to major data regions and let the plugin self-serve would of course pin Toady down severely.  (It also would make it trivial for the plug-in to break the rules I've proposed to prevent a DF-wrapper).

But a higher-level API, where information is given as text strings rather than internal code, could be stable so long as the game maintains a fortress mode.

ie:
Code: [Select]
    ws = find_a_workshop("carpenter");
    if (ws)
    {
          add_workshop_job(ws,"larch","bed");
    }

Note that so long as the wrapper is prevented, there is no need to rush and provide API access to everything.  Toady's fear, as I understand it, is that new users will abstain from trying new features if they cannot access them through their favorite wrapper -- thus pressuring him to rush out new APIs and then lobby wrapper authors to use them.
Logged

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Toady-safe manager plugin
« Reply #3 on: April 16, 2011, 11:51:18 pm »

Well, let me start by throwing this in here:

Anyway, yes, this has been suggested before and Toady has made a couple direct responses.  Any supporters of the idea should definitely read these:

Spoiler: response (click to show/hide)

Spoiler: followup (click to show/hide)

Also some earlier stuff:

Spoiler: part 1 (click to show/hide)

Spoiler: part 2 (click to show/hide)

If you want to make an argument for an API, this is the argument Toady has made against it that you have to overcome.

You have to convince him that the risks are mitigatable, and that it would be fairly simple to pull this sort of API off.  It probably wouldn't hurt to either create or link to instructions on how to create useful APIs, since Toady may not have any experience with creating an API.

It would probably also be best to couch your argument more in the terms of how people already wait upon programs like Dwarf Therapist to play DF, and cannot play DF without it, and how the API can be built without needing maintenance from Toady and makes the outside programs work with DF better, resulting in less of a headache for him, and not more of one.

Toady also likes organized threads.  Rather than a running argument back and forth in a thread, try to put everything you really need to know about the thread in the first post, and just link to the important arguments in the thread if need be.

Good luck, and godspeed.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Michael

  • Bay Watcher
    • View Profile
Re: Toady-safe manager plugin
« Reply #4 on: April 17, 2011, 12:49:00 am »

Well, let me start by throwing this in here:

(... extended footkerchief quote elided by Michael ...)

If you want to make an argument for an API, this is the argument Toady has made against it that you have to overcome.
Actually, I read that before I even started this thread.  It's just that I think his point about being forced to keep adding API features at the same rate of new native-UI commands only applies if people use the plugin interface to create DF-wrappers -- and the time lag would prevent that.

It would probably also be best to couch your argument more in the terms of how people already wait upon programs like Dwarf Therapist to play DF, and cannot play DF without it, and how the API can be built without needing maintenance from Toady and makes the outside programs work with DF better, resulting in less of a headache for him, and not more of one.
I'd hesitate to use that line of argument.  A lot of the existing debugger-based tools do things that my API would never provide, such as outright cheating.

I don't think it possible to make an API complete enough to eliminate entirely the inclination to hack DF's address space without raising the specter of a wrapper (and then most of Toady's complaints would become quite valid).  So it won't make DFHack go away.

But I'm not looking for an API that complete.  A limited one, with the time lag and a few simple commands, would be still be quite useful.
Logged

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: Toady-safe manager plugin
« Reply #5 on: April 17, 2011, 02:51:29 pm »

But I'm not looking for an API that complete.  A limited one, with the time lag and a few simple commands, would be still be quite useful.

In that case, you should edit your initial post to make that very explicit to the sort of person who only skims most threads (and change the subject line to match).  You have to make this argument convincing to Toady, now, not necessarily us, and he has a lot of things to read.

You're using terms like "API", which is colored by the preconceived notion of the arguments that have taken place before this one. 

No, it's not really fair, but it's true that people pass judgment fairly quickly on these things, especially when they see key terms that they have already loaded with emotions like "API" is because of previous arguments.

You should clear off that first paragraph of the original post, it doesn't have much to do with the argument.  Toady knows what's already been on the ESV.  The second paragraph doesn't need to be there - you're arguing to us in that paragraph, not Toady.

If you want to argue for this on the basis of it not being capable of breaking anything else, you should do a quick talk about the specific problem this specific solution will solve, and then go about talking about how it would be both easy to implement and would not require updating and would make Toady's maintenance of the game easier overall.
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Draco18s

  • Bay Watcher
    • View Profile
Re: Toady-safe manager plugin
« Reply #6 on: April 18, 2011, 10:09:16 am »

Only if the API is designed lazily.  An API that simply gave out the pointers to major data regions and let the plugin self-serve would of course pin Toady down severely.  (It also would make it trivial for the plug-in to break the rules I've proposed to prevent a DF-wrapper).

But a higher-level API, where information is given as text strings rather than internal code, could be stable so long as the game maintains a fortress mode.

ie:
Code: [Select]
    ws = find_a_workshop("carpenter");
    if (ws)
    {
          add_workshop_job(ws,"larch","bed");
    }

Just FYI:
A high-level API is harder to code than a low level API.  While more flexible, it takes a larger amount of code, with very broad definitions in the external interface portion that need to be narrowed down to figure out the specific object or task that the general socket applies to.

When you start taking input as textual strings, rather than as something concrete then you add in the additional overhead of having to parse and compare strings (string comparison is orders of magnitude slower than integer comparison; although not likely to be a factor for DF where the major bottleneck is pathfinding and object tracking*).  And remember, custom workshops are possible.  And custom items, reactions, creatures....

*If 100,000 stones isn't slowing down your game, I want to know what kind of computer you have.
Logged

devek

  • Bay Watcher
  • [KILL_EVERYTHING]
    • View Profile
Re: Toady-safe manager plugin
« Reply #7 on: April 18, 2011, 08:00:51 pm »

Only if the API is designed lazily.  An API that simply gave out the pointers to major data regions and let the plugin self-serve would of course pin Toady down severely.  (It also would make it trivial for the plug-in to break the rules I've proposed to prevent a DF-wrapper).

But a higher-level API, where information is given as text strings rather than internal code, could be stable so long as the game maintains a fortress mode.

ie:
Code: [Select]
    ws = find_a_workshop("carpenter");
    if (ws)
    {
          add_workshop_job(ws,"larch","bed");
    }

Wrong on a few points. DF is very alpha and many aspects about how it will work are undecided and will change. It is impossible to design an api for what you are talking about without limiting the creative development of DF.

It comes down to this... all third party utilities are already possible. If we spent the time doing it, everything you could imagine the hackers know how to do. The specific example you give is actually done by the program in my signature and is an open source project. The question is, should the burden of compatibility fall on Toady or the hackers?

With the system the way it is now, the hackers have no trouble interfacing with new versions of DF. What you're asking is for that burden placed on Toady instead, and for no real gain. The only reason there isn't a third party interface, is because no one has spent the time to write one.

If you let it up to the community to vote on, I bet you they would prefer Toady continue to make DF a better game and adding new features than waste time dealing with other programmers.

(Also, DF can't technically queue a job for a larch bed.. only jobs for wood beds will do.)
Logged
"Why do people rebuild things that they know are going to be destroyed? Why do people cling to life when they know they can't live forever?"