IF System that allows for slightly complex simulations?

I’m tinkering around on a story where I am wanting to do implement some simulations as part of story interaction. Is there a system that allows for custom code / math / etc?

I know I could do some such with Twine and Javascript. But I was wondering what other systems are worth considering?

2 Likes

In what way do you mean? Like one where math is possible in game? Or you can type in code into the command prompt while playing? Both of those have different languages I’d recommend.

1 Like

Specifically when developing the game it self - so elements of the game driven by math, not the game player typing in code.

Thanks!

2 Likes

Hmmm, I can’t help much with the idea of math in development. But recently @mathbrush made a game with a working calculator that had sin, cos, tan, etc. I’m not sure if that’s what you’re looking for but if it is, Inform (7 or 10, ask @Zed) is probably the way to go. I’m not very experienced in multiple languages so this probably isn’t helpful advice, but I thought it might be worth a try!

2 Likes

Such as? If it’s just some mid-level arithmetic, you could use choicescript. My latest game has a city management system which uses plenty of mathematical calculations.

If we’re talking about advanced algebra or geometry, I probably can’t help with that, unless you want to try creating an IF with Excel.

Inform’s certainly capable of it, like any Turing complete language. I’m not sure what kind of simulation you’re talking about, but if it’s some sort of physics simulator, I don’t think Inform’s especially well-suited to it. It’s not hard to imagine that what you want would end up being obnoxiously slow. And Inform’s not the easiest thing to learn: I wouldn’t recommend taking it on for this problem domain.

But simulation involving math could mean all sorts of things – if you tell us more about what you have in mind, we could give better advice.

1 Like

IF tends to be written in domain-specific languages nowadays, but I think some engine that’s written in a mainstream language will prove better for this. You can plug Box2D into Twine without too much effort, for example, since they’re both built on JavaScript, and put a rigid-body physics simulation in your game. Much harder to do that in Inform or TADS.

Unfortunately, if you want to do specifically parser IF, there aren’t a lot of options for that. I can’t think of any popular parser-IF language that can be easily hooked up to JavaScript/Python/C++/etc libraries. (Maybe Inform with Vorple? Or Inform with the new “compile to C” option?)

But if you want choice-based, there are plenty of options out there; Twine is the most famous, but Ink is designed to be hooked into a larger game engine of some sort (with bindings for Unity, Unreal, plain JavaScript, and probably more).

And of course, if you want to build your own simulation library, basically any modern language will provide the mathematical primitives you need. But, that depends on your willingness to build everything from scratch as opposed to importing a library someone else has already made and refined.

2 Likes

(Hmm…mini-comp where you have to integrate some other kind of simulation into your game…)

2 Likes

AFAICT, TADS has some speed issue in floating-point math, but Inventor200 can be more specific, having researched TADS’s floating-point handling.

I think that as language, Inform isn’t precisely suited for coding complex math.

If your math require player’s input, I think that the unique flexibility of ALAN allow building a formula-based parser (not Octave-grade, but I think that a bc-grade parser IS feasible), but ALAN’s underlying VM (story file format, in IF coding parlance) has only integer math.

Historically, Adventure was written in FORTRAN, a language designed for coding complex calcolations (FORmula TRANslation), so writing math-centered IF was feasible since day 1.

AFAICT, only two IF implemented a calculator, both in TADS:

3+ in TADS3 implements a four-operator calculator
GC: A trashing parity bit implements a basic RPN calculator in TADS2.

This is all I can say from your question so, I concur to others in asking more specific details on your question.

Best regards from Italy,
dott. Piergiorgio.

1 Like

Wasn’t Joey (@inventor200 ) working on simulating orbital mechanics and Jovian atmospheric pressures in TADS a while ago?

EDIT: Don’t know if it’s helpful, but here’s the thread:
Thankful For Mathematics - Authoring / TADS -

3 Likes

Yea, is that I refer in my post. Let’s leave to Joey the honour of narrating his simulating experiment.

Best regards from Italy,
dott. Piergiorgio.

1 Like

Never Gives Up Her Dead (@mathbrush) has a completely (TTBOMK) working calculator, in Inform.

Does it calculate 5318008?

2 Likes

Honestly, I wish I knew what that meant. Do you literally mean the number 5318008, or…?

2 Likes

Lamest example of pre-pubescent schoolboy humour. Type that number into your old-school calculator (with the square numbers), turn it upside down and read it aloud.

Oh how we laughed in grade school! Just like our first forays into the undiscovered realms of the dictionary…

3 Likes

Oh. My. Days.

As soon as you said the words “calculator” and “turn it upside down”… :laughing:

Where is the pained cringe laugh emoji when you need it?!?

3 Likes

Ren’Py can, in theory, do any mathematics that Python can do due to the way it interacts with the Python underneath. In practise, at beginner level, it’s good at the four basic operations, decimals and the sort of algebra where the letters are represented by numerate stats you are tracking (and where everything else is fixed numbers, four basic operations and decimals).

If you want a parser, I suspect several parser-based platforms would be equally accessible (Ren’Py is a choice-based platform) and that it is easier for a beginner to implement basic choice in a parser than a basic parser in choice.

1 Like

I don’t understand. Could you give some examples that describe what you intend?

Thanks! I’m basically playing around for a different project with a simple simulation of the movement of water on things submerged for instance if you drop something in that will sink - say something metalic - how might the flow of water, smoothness of the bottom (bedrock/sand), etc - move.

I’ve been programming a long while (30+ years) and have played with Inform and TADS in the past and wasn’t really seeing how to approach such. For game play, I could use randomness/percentages but was wanting something a bit more indepth.

1 Like

Thanks!