twine ren'py alternative game engine that supports multithreading?

Looking for an alternative that is similar to twine or ren’py that supports multithreading. Any suggestions are welcome.

Why do you want multithreading for a visual novel?
I don’t see how you could actually utilise any one core with that.

cacluating 1500 - 5000 npcs turn when there is over 7million possible combinations to make up each of their turns requires more than 1 thread to be done in a timely manner.

1 Like

Few 2d engines support mulithreads for the scripting components. However, python has mulithreading built in. JS(for twine) can do it but is not built in I don’t think.
You could probably send up a data structure, sent them out to be completed in the threads then process the returned data in the main script thread.
Alternatively unity and unreal have it. Unity’s is an engine feature while unreal has it built into c++.
You may even benefit from doing it as a compute shader on the gpu. CPUs at most have 8 logical core. Sometimes 16 but that’s on above most. Any more threads than the max will not give further benefits. GPUs are a bit more limited but have way more parallel processes.

1 Like

Ok, well I was hoping someone would have an answer other than unity or unreal engine, seeing as with those theres a lot that twine and renpy already have built that i would be rebuilding.

Also unless my understanding is mitaken, while python has a mutithreading library the GIL(Global interpreter lock) prevents making any good use of it, and renpy just flat out does not support it. Javascript has no multithreading im aware of(mainly because browsers don’t support it/need it).

Multithreading in JS is hardly impossible, just something that’s not commonly noticed by the end user. I know nodeJS supports it, anyways.

Regardless, I would argue that your problem is more likely related to how your code is written and optimized than it is about how many threads are available. Even if you have 7.5 million options for each NPC, it’s not like you need to be checking each possibility. Even with extra steps for weighting certain options, you’re essentially picking six random numbers per NPC and running the outcomes of those. If those outcomes require more complex calculations than a couple quick variable changes, then you’ll run into speed issues there too.

I haven’t taken a look at your game, but I would first question why you need complex simulations for thousands of NPCs; that’s far more than a player will ever meaningfully interact with, and if you’re storing them all, you’re creating a massive, unwieldy data structure that’s likely going to cause problems somewhere down the line no matter what you do.

Ren’py and Twine are tools designed to make simple, choice-driven narratives; while pulling in extra Python code might help in the former’s case, neither are designed to handle complex data structures or heavy loads of math.

1 Like

ok but nodejs is a server side js implementation of js and it uses the v8 core which is a single thread per process js interpreter. so my understanding is its implementation is closer to multiprocessing than multithreading. This is all irrelevant however because nodejs is for running js outside the browser. and twine runs in the browser which’s sandboxes tabs or websites to a single process.