Gamebook store

Friday, 11 July 2025

The magic of the machine

All five Vulcanverse books are now available in ebook format for Kindle and as watermarked PDFs on DriveThruRPG. If your friends scoff at the very suggestion, saying, "But the full-colour hardbacks look so amazingly collectible!" -- well, they have a point, but you can counter with the fact that you'll be getting the entire open-world series (6115 gamebook sections, and getting on for three quarters of a million words) for less than the price of a single paperback book.

The Sisyphean task facing me was hyperlinking all those sections. You can see from the image above what the text looked like. I had the five books in Word and I was quickly able to convert all the centred numbers to headings. You can hyperlink to headings, so that was the first hurdle. But then I thought about the task ahead. More than six thousand sections meant about twelve thousand hyperlinks to put in. If I did those by hand it would take weeks of mind-numbing labour.

Ah, but that's 2024 thinking. We're in the future now. I keep extolling the benefit of writing with AI. What better use of it could there be than saving me hours and hours of drudgery? I presented the problem to Gemini 2.5 Pro:

"I have several Word documents into which I need to insert hyperlinks. Each document has numbered sections, typically from 1 digit to 4 digits -- so, for example, 1, 2, 3... to 1499, 1500, 1501, say. Those numbers are styled as headings in Word. Then in the body of the text I have a bunch of links, also numbered, like so: ► 1, ► 2, etc. I want to link those so that the number after the arrow is hyperlinked to the corresponding heading. For example, given ► 188 the "188" would link to to the heading labelled 188. Rather than do this laboriously by hand, I'm hoping you can write me a macro that will add all the hyperlinks automatically."

Gemini quickly came back with a macro to run in Word. And here's a bonus: a human coder would certainly have told me that I should have written the book in Twine to begin with -- in other words, "I wouldn't start from here." But I had it all in Word, so who cares what I should have done if I'd thought about it a couple of years ago? I needed the solution to this problem right now. LLMs don't scold you, they just get on with it.

Gemini's macro hyperlinked the whole of a Vulcanverse book in a few minutes. The only snag was that it hyperlinked every instance of a number N to heading N, and that included hyperlinking stat bonuses, the costs of items for sale, and numbers given in difficulty checks -- whereas I only wanted it to hyperlink numbers that followed a ► , ie in the format "► N", indicating a player option. Gemini suggested a couple of fixes but those didn't work. At this point it was time for the human writer to earn his keep. I said:

"The new macro is inserting hyperlinks for all instances of ► N but also hyperlinking any number N regardless of whether or not it was prefixed by "► ". I have thought of a possible solution that would save me having to completely reformat the original document. What if I replaced all "► N" with "► xyzN". If you rewrite the macro to search only for "xyzN" and hyperlink those, I can then globally remove the "xyz" and we should be left with hyperlinks only where we want them. I suggest this on the theory that it's the search for ► that is confusing the VBA editor."

That met with Gemini's approval. "Your proposed workflow is a classic troubleshooting technique," it said. "If the target is ambiguous, make it unambiguous. By 'salting' the numbers you care about with a unique prefix, you create a perfect, undeniable target for the macro, completely eliminating the possibility of it acting on the wrong numbers. I am confident this will work."

The best-laid plans of mice, men and machines... The new macro added the hyperlinks, and as promised the hyperlink was only on the numerical part of any instance of "xyzN" (so that I could remove the "xyz" without losing the link), but any given link for a number N didn't necessarily point to the heading N, but to the first occurrence of the number N anywhere in the Word document. Since a number frequently might be mentioned before the heading corresponding to that number, we were still stuck.

My first thought was that the macro was having trouble identifying the headings, so a possible fix would be to run a macro that created a set of bookmarks from the headings. So, for example, heading 323 would lead to the creation of a bookmark labelled bookmark_323 (because bookmarks can’t have names that only comprise digits). We’d end up with a bookmark list: bookmark_0001, bookmark_0002, etc, all the way to bookmark_1800 or whatever. Then we could run a modified version of the hyperlinking macro that would only link to corresponding numbers in the bookmark list.

By this point I'd begun to lose confidence in Gemini 2.5 Pro so I turned instead to Claude Sonnet 4. I didn't give Claude my proposed solution of creating a bookmark list as I wanted to test it properly against Gemini, so I just showed it the macro I had been using and told it the problem. "I can see the issue with your macro," said Claude almost immediately. "The problem is in how you're creating the hyperlinks. When you use SubAddress:=headingNumberText, Word is searching for the first occurrence of that text anywhere in the document, not specifically looking for a heading with that text. The solution is to create proper bookmarks for your headings first, then link to those bookmarks. Here's a corrected version of your macro that should work properly."

Now, this was encouraging. Claude had come up with the same solution as me (not always a good sign in and of itself, admittedly) and its code was considerably tighter than Gemini's. Not only that, Claude's macro ran faster and with no errors. Some twenty minutes later I had all five Vulcanverse books fully hyperlinked. (And the Fabled Lands books after ten or fifteen minutes more.) It's a perfect example of how AI tools can make a writer's life so much easier. All the words and storylines are by me and Jamie, all the illustrations are by Mattia Simone and the art team at Vulcan Forged; only the grunt work was done by machine.

No comments:

Post a Comment