## Solving a gamebook : can we solve five books at once? The 2022 update.

### This post is part of the "Gamebook solver" serie:

- Solving a gamebook : introduction
- Solving a gamebook : roadmap
- Solving a gamebook : chapters
- Solving a gamebook : game state and probability
- Solving a gamebook : implementing the combat system, and first optimizations
- Solving a gamebook : solving the cartwheel game
- Solving a gamebook : a smarter solver
- Solving a gamebook : a simple solver
- Solving a gamebook : the Rust rewrite, teaser
- Solving a gamebook : revenge of the Haskell solver
- Solving a gamebook : can we solve five books at once? The 2022 update.
- Solving a gamebook : Lone Wolf book 05, Shadow on the Sand mega solution (edit)
- Solving a gamebook : Lone Wolf book 04, The Chasm of Doom

The Lone Wolf series starts with a five books arc. I now believe it might be possible to solve all of them at once, and compute the ultimate walkthrough!

The reason why it might make sense to solve them all at once instead of in isolation is that there are elements that are kept between books, namely selected disciplines and items. This means that some high-risk items might not be worth it in a book, but very much worth it in a subsequent book.

Since last time, the following items were improved:

I finally implemented the healing discipline properly ... at least kind of properly. This changes everything with regards to balancing, which means that all previous statistics are to be discarded :)

I also implemented book 05. This book has several specific mechanisms. There is poisoning, disease, and equipment confiscation. The latter is especially costly with regards to performance, as a copy of the inventory must be stored ...

... but now that I can't fit the state in 96 bits, there is more space for extra items :)

# Notes on solving Book 05

Note that everything here is to be considered with suspicion, as there might be bugs lurking in the way I encoded the books (I just found one this morning where I forgot to encode a shop).

Book 05 has 400 chapters instead of 350, and is noticeably more complex than the others, which makes computation much more taxing. As a result, I decided to compute the stats only for *hard mode* Lone Wolf, that is with a weak (10 skill, 20 endurance) character. This is offset by the fact that you wield the *Sommerswerd*, but well, it is still hard :)

The other consequence is that I had to buy an extra 64GB of RAM for some computations to eventually complete. Of course, I later optimized it and everything fits in 20GB, but at least I can run more jobs in parallel :/

There is an interesting part in this book, where you can get imprisoned, and your equipment is seized. Later, there is the opportunity to retrieve it.

It turns out that it is never worth retrieving it!

- if you wield the
*Sommerswerd*, it makes more sense to avoid this episode entirely, as the weapon is too valuable to be lost, and strong enough that you can withstand the harder route ; - if you do not wield it, then the equipment you find is plenty sufficient, and it is not worth it trying to get your previous stuff back.

Contrast this with this walkthrough, where it recommends recovering the equipment! Also in this walkthrough it recommends items from previous books, but I did not find they made any difference :) I still have to compute if having previously fought an Elix , or having received a Crystal Star Pendant makes a difference!

But perhaps for a stronger character, or a character with only 5 disciplines, it is very much worth it.

# Notes on healing

Healing changed everything. In book 05, section 98, if you go to chapter 118, you have 1/10 chance of dying, and 9/10 chance of ending up at the same place you would be if you chose the other path. It seems like it is strictly better to avoid this path, but my solver sometimes chose the "wrong" path anyways!

It turns out that there is a fight just after, and the "wrong" path, being longer, let you heal some more, which makes a difference for this fight!

# Next time

Hopefully, next time I will have a solution for the whole five books :) I still have to model book 03 (book 04 is done but needs debugging), and to write a way to stitch them together. I am however confident this is computable, so let's check it again next time!

# Bonus

click here for a solution visualization of the following starting state:

- Max endurance 20, skill 10
- Sommerswerd, 1 potion of Laumspur, shield, 2 meals