Gamebook Character Autoroller

I made a character generator for gamebooks. This is another one of my “I made it for me, but I’ll share it with the public” things. It’s basically a configurable auto-roller, because nobody wants to start with a poorly rolled character that they know will instantly lead them to a gameover in the first battle, and rolling additional characters takes time.

You can grab it here: (3.3 KB)

It looks like the image below (which coincidentally happens to have the same background color as this site’s dark theme, which I didn’t realize until posting this):

The utility is just an HTML file with a bunch of embedded JavaScript. The JS is intended to be edited by the user to add new games or adjust options. I considered adding a UI to change the options, but A) I’m lazy, and B) the options are mostly based on preference and once you find something you like, you probably won’t change them again.

Here is an example of the games definition:

var games = {
    "Fighting Fantasy": {
        Skill: "1d6+6",
        Stamina: "2d6+12",
        Luck: "1d6+6"
    "Lone Wolf": {
        // Lone Wolf is zero based so we subtract 1
        "Combat Skill": "1d10+10-1",
        Endurance: "1d10+10-1",
        // don't include gold in stat sum
        Gold: "!1d10-1",
        Weapon: [
            "Dagger", "Spear", "Mace",
            "Short Sword", "Warhammer",
            "Sword", "Axe", "Sword", 
            "Quarterstaff", "Broadsword"
    "Isle of Doctor Moreau": {
        Prowess: "2d6+6",
        Ballistics: "2d6+6",
        Vitality: "2d6+12",
        "Ranged Defense": "2d6+6",
        Fate: "2d6+6"
    "Entram": {
        Body: "1d6+2",
        Mind: "1d6+2",
        Heart: "1d6+2",
        Spirit: "1d6+5"

Basically the format goes like this:

"Game Name": {
    "Stat Name of Dice Roll": "1d6+1-1",
    "Stat Name not included in Sum": "!1d6+1",
    "Stat Name of Item List": ["Item 1", "Item 2", "Item 3"]

For dice rolls, they must be in the order of “1d6+1-1”. That means the plus amount must come before the minus amount or it won’t parse right. I could have made it detect the change of position order, but A) I’m lazy as previously mentioned, and B) the intention of the calculation could be misconstrued.

To prevent a roll from being added to the sum (like gold in the above Lone Wolf example), just place a ! in front of the dice roll. One side benefit of this is that you can place a ! in front of all but one stat and it’ll sort all rolls by only that one stat.

These are the option settings:

var options = {
    total_rolls: 50,

    stat_names_first: true,
    ascending: false,
    show_max: true,
    pad_places: 2,
    only_allow_average: true,
    average_tolerance: 1
  • total_rolls: number of characters to roll
  • stat_names_first: whether to show stat names before or after values
  • ascending: whether to list characters in ascending or descending or according to total values
  • show_max: output the values twice; one for current score and one for max score
  • pad_places: number of places to pad out spaces before values for proper alignment
  • only_allow_average: will only display characters whose totals are within the tolerance of the average
  • average_tolerance: the tolerance plus or minus within the rounded value of the average

With these default settings, it rolls 50 characters, determines the average by summing the stats of each roll, and then only shows the characters that meet the average plus or minus the tolerance.

If you disable only_allow_average, it will show you all 50 characters. If you decide to turn that off, you may want to only roll 10 maybe. But be warned that you can roll some really poor characters if you have such a small selection. The whole point of this utility is to A) let you choose from a wide selection of characters with decent stats, B) shoot towards the average, which means that it’s not possible to roll a god character or a crap character.

I personally prefer the stat names to be first, but you can switch it so that stats themselves go first with the stat_names_first option. It’ll look like this:


The show_max stats simply duplicates the stat name for convenience (but not items in an item list):


You may be like “But why…?” And reason is that because I like to write my gamebook character sheets like this:

469: After defeating Verity

Stats    max  current
Body       6:  6
Mind       5:  4
Heart      5:  5
Spirit     9:  7

Enemy:  B:6  S:7
Enemy:  B:8  S:9


Meal pack* x1
Stun grenade* x2

Ring engraved with a leaf and "36"
Business card: 147308

Trapdoor under the ??? marked with chisel.
The sniper's name is Hukulu.

Meal pack: 
    restore 4 spirit on non-combat section

Stun grenade:
    VS humans: one extra attack
    VS aliens: 1-3: no effect
               4-5: one extra attack
                 6: two extra attacks

I find this format works really well. But the important part about the stats is that a lot of gamebooks have an upper limit of stats. For example your spirit (which is your health in this one) can decrease, but it won’t ever increase beyond what you rolled for your character, unless it specifically says you can increase it. The other stats work the same way. So it’s important to always have the original stat on hand. Auto-duplicating it just saves typing by letting you copy the whole thing directly into your text file.

Anyway, that’s it. I hope it’s useful to someone, even though I know gamebooks aren’t all that popular here (or anywhere, really).

Edit: I added the feature to exclude rolls from the sum using !.


Cool project! I enjoyed gamebooks a lot when I was younger and still have several of them sitting around gathering dust. Something like this might go some of the way towards reducing the overhead of playing them (compared to doing something easier and with less setup like fully-computerized IF or other video games with more aggressively rewarding gameplay, watching videos, doomscrolling, etc., etc.). I might give this a poke and see if it’s the kind of nudge I need to try completing one of my old books for the first time in at least a decade.

1 Like

Just a thing to point out if you use it:

The list always orders them (either ascending or descending) by the sum of their stats, so the best ones are aways at the top or bottom.

Using that, you can alter the average_tolerance to adjust the difficulty by letting the results be that much higher/lower than the average.

Right now it includes all numbers in the stats, but I’m thinking of making a slight alteration where you can maybe put a ! before either the dice roll or stat name so that it’s not included in the sum.

For example, gold in Lone Wolf is included, but that seems kind of dumb to have a character with a lot of gold be considered better than a character with high combat skill and endurance when you can get gold in the book pretty easily right off the bat but your other stats never increase.

Edit: I went ahead and added that feature. It’s in the zip file in the topic post now.

1 Like