Why on earth would anyone enter raw Python code into the Spring Thing?

Considering that King James Bible is 4 MB, I just have to wonder what is it that they put in there that merit that humongous size?

Well, at least it’s not 4GB like MSVS. That’s like LOTR–The movie!

I’m not really sure. My engine is definitely not 27mb in size. It’s like 3000 something lines and 85kb on disk, so I’m assuming a good portion of it is a running instance of chrome’s V8 JS engine or whatever, plus maybe browser extension instances. I’m not sure if they create a new one for each tab or exactly how chrome handles that. But even with that being taken into account, that’s a lot of ram!

Also 4gb for a movie sounds like you’re using h.264. Try HEVC (aka h.265). It’s about 1/3 the size and higher quality. :stuck_out_tongue:

2 Likes

There are a number of different approaches to embedding Python in JS, and you can watch Russell Keith-Magee perform a quick survey of the state of them in 2018 (evaluating the tradeoffs in size and functionality and convenience) here:

2 Likes

That page has multiple instances of the interpreter, and as the image contains a Python interpreter as well as dependencies and all library code it’s not going to be lean. I’m not sure how much attention most people still pay to games’ memory usage, but kind of sad when an IF game takes up more memory than AAA FPS shooters used to in the 2000’s.

1 Like

I pay attention to memory usage, especially if a purchase is involved. I’ve seen visual novels my computer cannot run due to requiring an i3 or 4 GB of memory, which I find difficult to comprehend. Why use those resources, when something more efficient would get the job done and be accessible to people playing on laptops that are more than 4 years old (because a minimum spec rarely results in the game running smoothly and quickly)?

(For anyone wanting a comparison, Valorant - a AAA FPS that was released last year - requires an i3 and 4 GB of memory. So a visual novel requiring one or the other is effectively saying it needs as many resources as a modern AAA FPS, never mind a 2000s one).

1 Like

If you watch the video I posted, you’ll see that there are a variety of Python-in-JS runtimes out there, and some are much larger than others. It’s worth looking into the smaller ones to see if they can fit requirements.

2 Likes

I normally don’t check. I usually only check it for my own engine to see how it’s doing. I did it in this instance because it literally froze my browser, which is something that never happens unless I accidentally write an infinite loop.

Just for reference, I have a 2.7ghz i5 with 32gb of ram.

I tried out Visual Novel Maker, which is a commercial app from the RPG Maker people, and it seemed like even in my tiny prototype tests, the compiled game was pretty enormous and had trouble running in some browsers.

VNs are mostly text and an engine that moves static sprites around, and since VNMaker has support for lots of extra premium things like lipsync to audio dialog, clickable image maps, and other extras, their engine might just be the equivalent of driving a tank to the grocery store for milk.

1 Like

Monogatari seems pretty cool. It has a nice looking demo and seems pretty optimized in the browser. It resizes well to various browser dimensions and chrome says it was only using about 60mb of ram for the demo.

Sadly, they opted to make this a JS library rather than an engine written in JS. IOW, all of your game script is straight javascript. I personally think that’s a poor choice and that they should have written a simple scripting language like Ren’py.

1 Like

Thank you, though to be clear I don’t intend to do this myself. Wish I had the time! I still have an Inform 6 game to finish some day :sweat_smile: But I’m sure it’s useful for those actually going that path !

1 Like

Have you tried P5.js? I think I’ll be going that route if I ever get to it. The standard library is 4 MB, while the minimum library is 800K. Not sure about RAM usage, though.

I have hacked out some prototypes to explore ideas in Python. My most solid one was “every object has a set for each relation (in, on, unlocked-by, etc)” and I had some fun reimplementing basic movement, taking, and some more esoteric verbs. It’s worth exploring the “grain” of a language to see what sort of approaches it guides you into (as I did with the awk demo on the Cloak of Darkness page).

1 Like

This is a bit of a tangent, but I’ve done a couple of projects now where I used Python as a game scripting language – that is, small bits of embedded Python – not connected to the implementation of the game engine.

This required implementing Python in, e.g., Javascript. But only the simplest parts of Python. Game scripting requires expressions, if statements, some operations on strings and lists and dicts. It doesn’t require you to define new classes (those will be provided by the game) or support the entire Python standard library. It’s surprisingly manageable.

It’s an odd use case, but the fact that I’ve done it twice means that maybe it’s a good idea. (Or, you know, maybe it’s a terrible idea and I’m just stubborn.)

3 Likes

Given the subject line of this thread, I’d say it’s entirely back on topic!

1 Like

Except there’s no way to get the text to “instantaneous”. Why do VNs insist on having all the text scrolled out line by line even at the fastest speed?

That’s off topic, but just a gripe I have.

3 Likes

I share this gripe. :stuck_out_tongue:

FWIW, Ren’py and most commercial VNs let you have set instant text, but there are way more than I like that don’t let you. The worst is when they not only don’t allow instant text, but the fastest speed is slower than my casual reading speed. That means autoread mode is no good and I have to press a key to make it all display at once. So that’s two clicks per line. Considering a game like Fate/Stay Night is 37K lines (about 820K words), that’s a lot of key presses!

Here’s where a Web approach can provide benefits. The last few pieces I’ve made have parameters dwell and pause to control timing of the text (number of seconds per word, and per paragraph, respectively).

Over the web, you can simply supply those in a URL, like this:

http://my_if_piece.io/sessions/a1b2c3d4e5f67890/?dwell=0.1&pause=3

I spotted this in an Adafruit newsletter this afternoon. It produces an executable from Python code. It might be relevant to this thread?

Nuitka is a Python compiler written in Python. It’s fully compatible with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.

That seems pretty cool, but you still need to compile it on the target platform, it seems. So I could release a windows version, but I wouldn’t be able to release a playable version for Linux or Mac users because I don’t have those platforms.

Which unfortunately brings us back to the original problem that releasing source is the only real way of letting everyone (with a desktop) play python games.

…and this is why Budacanta defaults to “Instant”. I read much faster than the fastest “gradual word-appearance” speed I tend to see, so even on the first read-through, forced non-instant text tends to send me (metaphorically) up the wall pretty quickly.

I left the delayed options in purely because some players consider it traditional (the earliest VNs did this so the computers of the early 1980s could keep up, given that they were displaying Japanese graphics rather than Latin text), or easier to read (since the text appears a bit at a time instead of all in one lump). Though even here, voicing of any kind is a viable workaround for some people.

“Dwell” can be achieved in Ren’Py using the “cps” command, if it is for a certain part of the text. (It’s bad form to impose a speed of text production over the whole visual novel, because people expect to control that themselves). There’s no direct equivalent to “pause”, and in fact “pause” in Ren’Py refers to the game pausing for a certain amount of time or until an input is provided.

As for the raw Python code… …it doesn’t solve the developer problem, but it does mean that players who encounter a game in raw Python code can self-compile it and play it (provided the version’s compatible with their computer - I still can’t play Theatre of Spud, but now I can compile Space Diner and find out what the fuss is about!

2 Likes