Taking random generation to the extreme.

Discussion in 'Story Ideas' started by Lilyflier, Jan 20, 2025.

  1. Lilyflier

    Lilyflier Virgin

    While there's no official way to randomly generate things on CHYOA afaik, there are plenty of unofficial methods to achieve a result that could suffice in many cases.
    • Instruct the reader to roll a dice or flip a coin or click on a link to a site that generates a random value, and then instruct them to select a chapter accordingly.
    • Have the reader make choices for which they have a roughly equal odds of selecting any choice. Then use that to influence seemingly unrelated things.
    • Create a grid of characters each linked to a different link chapter that changes variable(s) in some way. Then ask the reader to select one randomly.
    • Create a pseudorandom number generator (PRNG) using lots of link chapters.
    What to generate
    So what all can we use this random (or "random") data for? Here are my ideas.
    • Companion's personality traits.
    • Companion's appearance traits.
    • Plot fetishes.
    • Plot points.
    • Locations/biomes.
    • Items.
    • Monsters/creatures/npcs.
    • Who you are.
    • Fundamentals that are then put through a smart algorithm to determine what some above things should be, to make the experience more cohesive while still generating exciting and unexpected outcomes.
    I think all of the above could massively improve from changes to game mode variables that make sense and can lead to emergent problems, solutions and behaviors. Like location "cliff" sets "high" to true. Item "rope" sets "can traverse high" to true. Plot point "rival appears" mixed with the cliff causes "Your attempt to navigate the obstacle was thwarted. {Rival} stands atop the cliff with a maniacal grin."

    The point is to get creative with it, consider the limitations and see if you can manage to randomly generate unconventional things. And if you're feeling ambitious, take things to the extreme until even you don't really know what's going to happen and can enjoy new things every time you read.

    With PRNGs in particular, I think we could make some really interesting things.
    • A large open-world (one very long chapter filled with if statements and having link chapters to change x and y variables and do all actions in the game) where a PRNG's seed is set according to where you are when you move, and then it runs. (You're guided secretly or overtly to select link chapters which make the PRNG generate some random bits/numbers.) The resulting bits can then be used for things like what sort of location it is, what sort of person(s) belong there, what sort of plot points you'll encounter, etc.
    • A fighting memory game with a binary tree. One PRNG is used to decide what decision the opponent makes (with a seed set with their stats and/or the day to keep their moveset from repeating for the most part). And one PRNG is used to determine what the correct response is from the reader. You could use the opponent's level/rank/whatever to determine how many rounds to do, and you can create image(s) that the reader can look over to learn what all the correct answers are at each point in the binary tree. Each round doubles the total amount of possibilities, so for the reader to beat an enemy, they'll either have to get lucky or memorize 2^Opponent level-1 binary answers. And of course erotic rewards could be included.
    Buying time
    Players are going to have to spend a decent amount of time selecting link chapters that generate numbers/bits for whatever is being randomly generated, especially when a lot of (or really big) random values are required. How do we keep the reader entertained while this is happening?
    • It could be canon that you use a large vehicle to navigate the world, and while you're traveling you can do various activities (most or all of which use link chapters that contribute to the pseudorandom generation).
    • In situations where it isn't very important to keep the reader from predicting what the final value is, the bits/number parts generated each time the reader selects the next link chapter can be used to determine some smaller events/things to keep them entertained.
    Making PRNGs in CHYOA
    How do you even make a PRNG given the limitations in CHYOA's game mode? I won't go into too much detail unless people really want me to, but I'll try to explain the basics. LFSRs (Linear Feedback Shift Registers) are the best type of PRNGs I've found that can be implemented in CHYOA, and the simplest ones only involve XOR gates and sometimes bit shifts. Plenty of online resources exist explaining how they work better than I could, so I'll mostly focus on how to implement them into CHYOA specifically.

    An XOR gate takes two inputs and checks if only one is true instead of false. If it is, it outputs a true value, otherwise it outputs a false value. To simulate one of these, we can create 4 link chapters for each of the 4 possibilities. They should function like "If we're simulating the XOR right now and the input values are 0 and 0, the output value should be 0."
    But each chapter addresses a different possibility for the inputs and changes the output accordingly.

    A bit shift (for our purposes) takes a series of bits and moves them all one space to the left or right. The last bit (which went "over the edge") gets taken to the first bit's empty place. To simulate this, we create a series of variables that is the length of the series of bits + 1 (the +1 is a variable that's used temporarily to hold the last bit while it's "over the edge"). We can then create link chapters that do checks like "if this is second to last step of the bit shift and bit 1 is 0 and bit 2 is 0, set bit 3 to 0 (set it to bit 2's value) and set bit 2 to 0 (set it to bit 1's value)".

    We can create more link chapters to account for more input possibilities per reader click, allowing us to simulate multiple XORs and/or bit shifts at once. But of course the more you want to simulate at once, the more the link chapters you have to create will exponentially increase.

    Conclusion
    If you're actually crazy enough to try this, feel free to reach out to me. There are dozens of complications I left out and I can save you a lot of time since I've done a lot of experimentation and found more efficient circuits for CHYOA that aren't easily found/understood online.

    Oh yeah, and if you have any other ideas for random generation, please comment them. I'd love to yoink them.
     
    lady-lux likes this.
  2. lady-lux

    lady-lux Really Experienced

    I haven't really dared to try working with story mode at all yet, so this is definitely too complicated for me to even look at, but it sounds like it has very cool possibilities! I hope you get the chance to do something with it. :)
     
    Lilyflier likes this.
  3. Lilyflier

    Lilyflier Virgin

    I've been trying! I got close to implementing the logic for one but I made a mistake and would have to remake a few hundred link chapters, and that demotivated me a lot. I might go for a different design or remake it in a few months when I get excited about that particular idea again though.
     
  4. Audiflex

    Audiflex Experienced

    This is next-level creativity, turning CHYOA into a coding playground with PRNGs and XOR gates? Wild. Love the idea of randomizing traits, plot points, and even combat systems. Sure, it’s a ton of work, but the payoff could be insane. If anyone pulls this off, they’re basically a CHYOA wizard.
     
    Lilyflier likes this.
  5. Lilyflier

    Lilyflier Virgin

    Thank you! And I completely agree, a ton of work with a potentially insane payoff. With the lack of flexibility in CHYOA's game mode, it would honestly probably be better to use a proper game engine or Twine or something for the most ambitious ideas here, at least while designing it. But it would be awesome to see game mode taken to its limits one way or another.
     
    Audiflex likes this.
  6. I have done something like this.

    Well, kind of sort of.



    upload_2025-2-12_9-56-24.png upload_2025-2-12_10-9-25.png


    My understanding of computer science is limited at best and I am not really that interested in actual random generation of content (at the very least when it takes this much effort to just generate random numbers). So I went for the analog approach and just encoded actual dice rolls into a lot of chapters (with the final chapter used in generation obviously taking precedence). The more involved variant of
    if you will.

    My main interest was to simulate an RPG skill/ luck check where the outcome doesn't just compare against a skill variable for a binary and predetermined outcome but takes luck (or "luck") into account. I have a chapter using these rolls as checks rather than pure flavour pre-written already, but it is not scheduled to be released for another month or so (current estimate, probably longer to be honest).


    The drawback are that you need a) much more chapters than possible results [and those do take time to fill out - arguably too much time] and that I b) am unsure how random the end result really is (my maths is if anything worse than my CS). And I do wonder if my results would have been better ("more random") if I used bit shifts (or seeded dice rolls mixed with bit shifts).

    I am honestly not sure if I understood all the logical implications of the more technical approach presented here (I definitely don't get the point of XOR gates yet) , so I may have more to say after I had coffee.
     
    Last edited: Feb 12, 2025
    Lilyflier likes this.
  7. Lilyflier

    Lilyflier Virgin

    That's excellent, definitely a missed opportunity by me to include that approach in the list of ways to "randomize" things.

    That makes total sense, the PRNG approach especially involves a very large amount of effort for very few pseudorandom bits, it certainly isn't a good fit for every project.

    I like that.

    Yeah, it does need a ton of link chapters and the randomness is not perfect. In my testing I've found that the values are random enough for my purposes, but feel free to check it out yourself (using scratch because I'm a horrible and lazy coder and couldn't be bothered using something better. Also if you do visit, please spare me the embarrassment of looking at the other projects I've unfortunately shared): https://scratch.mit.edu/projects/1116337449/

    I think the XOR gates are used to mix up values in a way that, when mixed with bit shifting, is difficult for us to intuitively predict or find obvious patterns with. And, with the right taps, you can get a maximum-length pseudorandom sequence that goes through every possible combination of bits except for all 0's or all 1's (I forget which).
     
    uthervierdragon likes this.
  8. RicoLouis

    RicoLouis Really Really Experienced

    if you just want nudes try tensor.art
     
  9. gene.sis

    gene.sis CHYOA Guru

    A simple version to use Random Numbers has been implemented for Score Changes recently. For the usage of the feature, see Creating Random Numbers.