Solving a gamebook : the Rust rewrite, teaser

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

This is a teaser post, for the ongoing work on solving the second book of the Lone Wolf series.

Last year I decided to rewrite the gamebook solver in Rust. It turned out to be much, much more performant, but also a lot more annoying to write. As a result, it does not yet work in all situations the Haskell version works, but it turns out I can finally solve book 02 in many situations!

What is done

The book is fully modeled, and can be solved in less than 2 minutes in most configurations on my computer. It can use an awful lot of memory though (around 6Gb in extreme cases).

What is to be done

Unfortunately, there are still a lot of things to work on:

  • publishing the source code for the Rust version ;
  • documenting and verifying that the heuristics I chose to reduce the search space are sound ;
  • extending the way the game state is searched to account for non-looping intersecting states (this is the cause of the 6th sense bug below) ;
  • as it is written in Rust, the code could be compiled to WASM, and an interactive solution explorer could be written very easily!

And in the long term, solving other books, or even solving books from other series.

Unfortunately, I am not that motivated to do that. So if you are actually interested in seeing any of that, please let me know!

Results

Weak character

Probability of winning, with skill 10, endurance 20, and the following pairs of disciplines:

Camouflage
Hunting
Sixth sense
Tracking
Healing
Weaponskill: sword
Weaponskill: spear
Mind shield
Mind blast
Animal kinship
Mind over matter
Camouflage - 0.00% BUG 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.30% 0.00%
Hunting 0.00% - BUG 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.53% 0.00%
Sixth sense BUG BUG - BUG BUG BUG BUG BUG BUG BUG BUG
Tracking 0.00% 0.00% BUG - 0.00% 0.00% 0.00% 0.00% 0.00% 0.14% 0.00%
Healing 0.00% 0.00% BUG 0.00% - 0.00% 0.00% 0.00% 0.00% 0.41% 0.00%
Weaponskill: sword 0.00% 0.00% BUG 0.00% 0.00% - 0.00% 0.00% 0.00% 3.75% 0.00%
Weaponskill: spear 0.00% 0.00% BUG 0.00% 0.00% 0.00% - 0.00% 0.00% 3.57% 0.00%
Mind shield 0.00% 0.00% BUG 0.00% 0.00% 0.00% 0.00% - 0.00% 0.30% 0.00%
Mind blast 0.00% 0.00% BUG 0.00% 0.00% 0.00% 0.00% 0.00% - 4.15% 0.00%
Animal kinship 0.30% 0.53% BUG 0.14% 0.41% 3.75% 3.57% 0.30% 4.15% - 0.30%
Mind over matter 0.00% 0.00% BUG 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.30% -

Average character

Probability of winning, with skill 15, endurance 25, and the following pairs of disciplines:

Camouflage
Hunting
Sixth sense
Tracking
Healing
Weaponskill: sword
Weaponskill: spear
Mind shield
Mind blast
Animal kinship
Mind over matter
Camouflage - 0.00% BUG 0.00% 0.00% 0.00% 0.01% 0.03% 0.00% 46.73% 0.00%
Hunting 0.00% - BUG 0.00% 0.00% 0.00% 0.03% 0.05% 0.00% 53.61% 0.00%
Sixth sense BUG BUG - BUG BUG BUG BUG BUG BUG BUG BUG
Tracking 0.00% 0.00% BUG - 0.00% 0.00% 0.00% 0.01% 0.00% 40.97% 0.00%
Healing 0.00% 0.00% BUG 0.00% - 0.00% 0.03% 0.05% 0.01% 50.86% 0.00%
Weaponskill: sword 0.00% 0.00% BUG 0.00% 0.00% - 0.02% 0.05% 0.00% 50.71% 0.00%
Weaponskill: spear 0.01% 0.03% BUG 0.00% 0.03% 0.02% - 0.22% 0.03% 49.83% 0.01%
Mind shield 0.03% 0.05% BUG 0.01% 0.05% 0.05% 0.22% - 0.07% 46.73% 0.03%
Mind blast 0.00% 0.00% BUG 0.00% 0.01% 0.00% 0.03% 0.07% - 67.80% 0.00%
Animal kinship 46.73% 53.61% BUG 40.97% 50.86% 50.71% 49.83% 46.73% 67.80% - 46.73%
Mind over matter 0.00% 0.00% BUG 0.00% 0.00% 0.00% 0.01% 0.03% 0.00% 46.73% -

Strong character

Probability of winning, with skill 19, endurance 29, and the following pairs of disciplines:

Camouflage
Hunting
Sixth sense
Tracking
Healing
Weaponskill: sword
Weaponskill: spear
Mind shield
Mind blast
Animal kinship
Mind over matter
Camouflage - 8.88% BUG 3.11% 8.09% 5.77% 25.90% 24.61% 7.08% 86.28% 5.47%
Hunting 8.88% - BUG 8.88% 11.40% 9.97% 40.43% 34.63% 11.17% 87.43% 8.88%
Sixth sense BUG BUG - BUG BUG BUG BUG BUG BUG BUG BUG
Tracking 3.11% 8.88% BUG - 4.73% 3.31% 17.61% 16.49% 4.32% 85.90% 3.11%
Healing 8.09% 11.40% BUG 4.73% - 8.43% 35.29% 32.13% 9.47% 87.24% 8.09%
Weaponskill: sword 5.77% 9.97% BUG 3.31% 8.43% - 26.13% 25.23% 7.17% 86.38% 5.77%
Weaponskill: spear 25.90% 40.43% BUG 17.61% 35.29% 26.13% - 59.92% 31.56% 86.48% 25.90%
Mind shield 24.61% 34.63% BUG 16.49% 32.13% 25.23% 59.92% - 29.69% 86.28% 24.61%
Mind blast 7.08% 11.17% BUG 4.32% 9.47% 7.17% 31.56% 29.69% - 89.07% 7.08%
Animal kinship 86.28% 87.43% BUG 85.90% 87.24% 86.38% 86.48% 86.28% 89.07% - 86.28%
Mind over matter 5.47% 8.88% BUG 3.11% 8.09% 5.77% 25.90% 24.61% 7.08% 86.28% -

Effect of skill/max endurance

Probability of winning, with animal kinship + mind blast, for various levels of endurance and skill.

Endurance:
20
21
22
23
24
25
26
27
28
29
sk: 10 4.15% 4.92% 5.69% 6.48% 7.34% 8.33% 9.44% 10.65% 11.87% 13.07%
sk: 11 13.40% 15.01% 16.65% 18.41% 20.31% 22.26% 24.16% 25.92% 27.55% 29.13%
sk: 12 23.04% 25.22% 27.22% 29.18% 31.21% 33.26% 35.21% 36.93% 38.39% 39.65%
sk: 13 35.68% 38.43% 40.76% 42.81% 44.79% 46.73% 48.51% 50.02% 51.22% 52.20%
sk: 14 51.46% 53.96% 56.02% 57.78% 59.35% 60.82% 62.13% 63.29% 64.29% 65.20%
sk: 15 58.71% 61.11% 63.12% 64.86% 66.38% 67.80% 69.16% 70.50% 71.74% 72.97%
sk: 16 67.25% 69.36% 71.16% 72.84% 74.39% 75.90% 77.37% 78.78% 80.06% 81.23%
sk: 17 74.26% 76.30% 78.05% 79.61% 81.08% 82.49% 83.73% 84.79% 85.62% 86.29%
sk: 18 79.88% 81.57% 82.99% 84.28% 85.39% 86.32% 87.04% 87.58% 87.98% 88.30%
sk: 19 83.24% 84.63% 85.82% 86.77% 87.47% 87.99% 88.37% 88.67% 88.90% 89.07%