Debugging how high a variable can go (not math clamp)

Twine Version:
[2.5.1.0]

Hi, I’m new. I couldn’t find anything on this topic so I’m hoping to get an answer or a “this is impossible” so I can continue on.

I’m writing a story with character stats based on ChapelR’s newmeter macro with, for instance, Hostile//Passsive meters that can go from 0 to 1 with .5 being in the middle. I already have Math clamp working, so this isn’t a question about how to make sure the stat doesn’t go out of those bounds. This is more of a testing question, to see if I’m balancing the stats correctly.

I did a little reading into Fair math which does seem to have merit in making sure the stat won’t go to it’s fullest too soon, which is one of my worries, but I don’t think it will work with this type of meter, and I could also be wrong.

Basically what I’m looking for is a way to easily test what the highest value of a stat can be in my game depending on your choices so far, as I would like to be able to set my stat gates realistically.

If this can’t be done could someone please give me a good alternative? Thank you.

Welcome!

I’m not familiar with a system to automatically calculate the maximum value of a variable based on all possible interactions with a game. I don’t think this is a SugarCube thing so much as a general game thing.

I do wonder if it’s feasible add some code to keep track of dummy stats that raise themselves at every possible opportunity your game allows?

However, if the game is simply too complicated to balance manually through play testing, perhaps put some friction on the way stats are raised. Make it so the cost to raise a stat is infinitely exponential. You’ll never get to 100%, but you can get close with a lot of investment.

Food for thought.

Good luck! I’m curious what the best solution to your problem is.

Before going into your question: Fairmath would for fine with Chapel’s meter macro, and can work quite nicely when the stat is getting to its lowest/highest.

If you want to test how high/low a variable can go (outside of the min/max you set in the Math.clamp() ), I would suggest using a separate variable, which increases/decreases the same amount as the base one, but without the Math.clamp().
Otherwise, you’d have to go through each passage (code, not play) and tally the added/removed points to the variable…

1 Like

As long as you use the Math.clamp() method, you should be able to dictate borns for every variables you deem troublesome enough to limit at any point of your story. It means you can cap the variable to a certain point, then remove or increase the cap to another point and so on.

So what you need is not to know what the maximum at a special point is, it’s to decide what’s the maximum you’re ready to allow at that special point.

I don’t think there’s a good way to do this in Twine. Choicescript has its randomtester which plays the game a whole lot of times and shows you the results. But I don’t recall seeing anything similar for Twine. Anyone?

It might not be terrifically hard to create JavaScript code to randomly play a Twine game and tabulate the results but I don’t think anyone has done it yet. So unless you’re willing to dive into web programming I suspect it’s a “this is impossible” thing for now, or at least a thing where you just have to test manually or ask other people to test for you…

1 Like

I have to say, thank you all for your input! Each one had an interesting take on the problem. After careful consideration, I have narrowed down what it is I’m looking to accomplish. I am looking for something that will automatically test out every pathway, very similar to what is described here: bradleycbuchanan .com /b/building-esthers-cafe/ (sorry, says I can’t post links) under “Structure and Tech”. This is their example output, but instead I would like to log the min, max, mean, and median for the stat values. Their code is for Snowman, though, so I don’t think I’d be able to use it?

# Every path
13:33 | Knots: 6507 | Endings: 45
Found 2793120 possible paths.
┌────────────┬──────┬──────┬──────┬────────┐
│  (index)   │ min  │ max  │ mean │ median │
├────────────┼──────┼──────┼──────┼────────┤
│ characters │ 5230 │ 8189 │ 6827 │  6856  │
│   words    │ 892  │ 1433 │ 1181 │  1186  │
│   knots    │  18  │  28  │  24  │   24   │
└────────────┴──────┴──────┴──────┴────────┘

Thank you! I already feel welcomes here. I have to admit that while I understand what you mean, I’m not sure how to accomplish this? It sounds like what I’m looking for, though it may not work for branching.

Thank you for your answer. For the meter, if the stat is something like .02 (Hostile) and they choose an option that is Passive, doesn’t that mean that with Fair math it would leap a ton? I don’t want one “out of character” choice to unfairly change the personality, which I guess is what I meant about Fair math not working with the meter, which I should have been more clear about.

This would still require manually choosing options, yes? I definitely want to avoid having to manually test, as the game will be quite long.

Are you saying that I should change the value of the Math clamps as the story progresses? That’s an interesting take I hadn’t thought of.

This put me down the rabbit hole and yes, randomtester/autotester are exactly the kind of thing I was looking for! Thanks to this, I did find another thread at infiction . org /t/anyone-tried-testing-with-selenium-or-similar/60222/4 asking pretty much the same thing that I was. If I understand correctly, something like selenium or puppeteer with a custom script will do the job?

1 Like

Indeed you’ve understood well what I meant.