Bay 12 Games Forum

Please login or register.

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

Author Topic: DFHack script: The Librarian  (Read 33015 times)

Leonidas

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #30 on: May 23, 2020, 02:08:35 pm »

And now it works again! Thanks!

Edit: I added a note in the Library wiki page about your script. As I see it, the current libraries are pretty much useless without it.
« Last Edit: May 23, 2020, 02:25:37 pm by Leonidas »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #31 on: May 24, 2020, 05:20:29 am »

Added a little support for competition and art references, and introduced line fitting for Detailed contents so they continue on the next line(s) rather than disappear over the edge of the screen.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack script: The Librarian
« Reply #32 on: May 24, 2020, 10:50:00 pm »

Btw, worth mentioning I did a small fix for 43.03, posted in full here: https://dwarffortresswiki.org/index.php/User:Fleeting_Frames/librarian

Change boils down to adding functions

Code: [Select]
function base2string(inputnr)
if inputnr <= 1 then return inputnr end
return tostring(inputnr%2) .. tostring(base2string(math.floor(inputnr/2)))
end

function base2string_To_Index_Truth_Table(inputstr)
local i = 1
local ret = {}
if not inputstr then return ret end
for i = 1, string.len(inputstr) do
if(string.sub(inputstr, i, i) == "1") then
ret[i-1] = true
end
end
return ret
end

then using

Code: [Select]
if ref._type == df.general_ref_knowledge_scholar_flagst then
          for l, flag in pairs (base2string_To_Index_Truth_Table(base2string(ref.knowledge.flags))) do

rather than
Code: [Select]
if ref._type == df.general_ref_knowledge_scholar_flagst then
          for l, flag in ipairs (ref.knowledge.flags.flags_0) do

(didn't recall this thread at the time of the posting; only the github, so it doesn't contain two most recent version changes)

PS: I'd suggest adding a picture in the OP; it's honestly pretty great for larger libraries and raiding.
« Last Edit: July 08, 2020, 11:22:21 am by Fleeting Frames »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #33 on: May 25, 2020, 03:49:13 am »

Sorry, but I fail to see what problem the convoluted code change fixes, so you'll have to explain it to me.

As far as I understand, the changed logic converts the flag data into a reverse order binary code string and then builds a sparse table containing the "1" entries as "true" in a bit + 1 table. I think that would cause the bits to be shifted one step, from a zero based indexing to a one based one, although further analysis would be needed to determine if the loops are the only usages of the indices, in which case it doesn't matter.

The original script logic relies on the fact that the data is a union, with all flags overlapping, and so it doesn't matter that we iterate over the first one (where all bits are used) rather than the one actually used, apart from accessing bits that should never be set in some cases.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack script: The Librarian
« Reply #34 on: May 26, 2020, 12:17:57 am »

43.03, the data is stored as just a number; script throws error in console due that and quits. This converts the number into something pairs can iterate over, i.e. 262144 is memory value that is = 2^18 (which pairs will complain about), but pairs({[18]=true}) works fine.

And...hm, you're right about it being off by one. I checked that example book got tossed right into geography, but it seems water cycle became "latitude climate zones". Whoops, stupid zero vs 1-based indices; ret[i-1] seems to fix that (edited on wiki).
« Last Edit: May 26, 2020, 12:20:25 am by Fleeting Frames »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #35 on: May 26, 2020, 02:18:56 am »

OK, if 0.43.03 just had a number there, yes, it would blow up (as it evidently did!). In 0.47.04 the overloaded fields are flag bit fields, so I don't see any need to change the script for the current DF version, as it seems your change was particular for your back ported version.
Logged

Leonidas

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #36 on: July 06, 2020, 08:40:43 am »

How many books would it take to overload this script? Could it handle 10,000?
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #37 on: July 06, 2020, 11:03:14 am »

Probably. It takes a significant time to handle worlds with 10000 books (a visible delay), but apart from time, memory would be the other constraint, and each book isn't using that much memory, so I'd expect slowdown to be the most problematic issue. Sorting books takes a fair bit of time (using exchange sort). Thus, it's probably more an issue of how long you're prepared to wait and how long lists you can stand scrolling through.
Logged

Leonidas

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #38 on: July 07, 2020, 10:22:12 am »

So it's already looking at all the books in the world, and moving those books into my fort won't change things much. That makes sense.
Logged

Nopenope

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #39 on: July 07, 2020, 10:41:11 am »

Now that GPT-3 is a thing and has a public API I wonder how hard it would be to send it the book descriptions as prompts and generate the books' contents on the fly.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #40 on: July 07, 2020, 11:59:30 am »

Now that GPT-3 is a thing and has a public API I wonder how hard it would be to send it the book descriptions as prompts and generate the books' contents on the fly.
I have no idea what "GPT-3" is supposed to be, but it sounds like you want to invent stories, which isn't compatible with the purpose of the Librarian, which is to show what's there in DF, even though DF's UI doesn't display all of it.
Logged

Leonidas

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #41 on: July 16, 2020, 09:33:15 pm »

Is there an efficient way to identify necromancy books? I'm shoveling books around by the hundreds, and I really don't want one to slip through and turn all my scholars into necromancers.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #42 on: July 17, 2020, 04:01:18 am »

Technically yes, i.e. it's possible to detect that a book contains a secret (and all secrets are currently about life and death). If I remember correctly, the script prints that a book contains a secret (and prints the text about what taken from the book, i.e. life and death in vanilla), but the script currently doesn't contain any search filter for it.

Edit: Updated the script to provide a crude Interactions view, plus handling of the addition of NONE to the Values enum.
« Last Edit: July 17, 2020, 09:12:42 am by PatrikLundell »
Logged

Silverwing235

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #43 on: July 18, 2020, 10:07:02 am »

Now that GPT-3 is a thing and has a public API I wonder how hard it would be to send it the book descriptions as prompts and generate the books' contents on the fly.
I have no idea what "GPT-3" is supposed to be, but it sounds like you want to invent stories, which isn't compatible with the purpose of the Librarian, which is to show what's there in DF, even though DF's UI doesn't display all of it.

...*ahem* If I may? You know that OpenAI dataset that didn't have its source released, because of fake news concerns? Well, this is that one's successor.
« Last Edit: July 18, 2020, 10:52:42 am by Silverwing235 »
Logged

Stiqy

  • Bay Watcher
    • View Profile
Re: DFHack script: The Librarian
« Reply #44 on: August 02, 2020, 07:27:20 am »

Is this a normal error in 47.04?

https://imgur.com/fKfFEI9
Logged
Pages: 1 2 [3] 4 5