[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 40965179.jpg (23 KB, 460x460)
23 KB
23 KB JPG
Hey guys, can 2 GB of RAM handle storing 20,000 lines of dialogue?

I’m making a game and want it to run on most computers, so I’m concerned about loading too much into memory.

I could load the dialogues only when they need to be displayed, but that might cause the game to pause for a second or two, which could break the vibe.

Right now, I’ve made the dialogues index-based by putting them inside an array—you need the index to call the desired line.

The problem is that putting all the dialogues in one array makes editing harder. If you add or remove something, you have to shift the indexes of most of the other dialogues. I did it this way because it’s faster than using a dictionary.

you can tell that am not really good at this

Do you guys have any better ideas to make this work?
>>
>>106742016
>can 2 GB of RAM handle storing 20,000 lines of dialogue?
If you have a text file with all the dialogue data or just a source file where it's embedded you can look at the file size. Loading the dialogue data up in memory will require roughly the same amount of memory as the file size with a bit of overhead
>The problem is that putting all the dialogues in one array makes editing harder. If you add or remove something, you have to shift the indexes of most of the other dialogues. I did it this way because it’s faster than using a dictionary
It's simple and good enough for your use case probably. But you could create a convenience script (that you run not the user) which creates a source file with the array based on some other more readable file format
>>
Yeah sure, text is not a big deal. But first make the game and worry about optimization later if necessary at all.
>>
>>106742016
1 character = 1 byte. how many bytes are in 2gb of ram, anon?
>>
These are the kinds of stupid questions that you should be asking an LLM. Or at least do the math on paper. Text takes no space at all. You are looking at like 10MB of ram max for a dialogue heavy game with no compression of the text whatsoever. Even if you support internationalization and have foreign languages you're not going to hit the limit.
>>
>>106742089
Oh, that’s brilliant, anon! I could make a script that automatically updates the indexes the way I want.
>>
>>106742107
>>106742140
>>106742160
Yeah, that should’ve been obvious, but you can never be too sure.
>>
>>106742016
What game anon? Also there is no reason to store that much text in memory.
>>
>>106742191
>I could make a script that automatically updates the indexes the way I want
Look into what makes most sense to you, use git or back up your data before runnin such script
>>
File: 1657642945396.jpg (22 KB, 288x288)
22 KB
22 KB JPG
>>106742210
yeah
>>
>>106742016
Unless you are adapting some dialogue-heavy book with each lone being a casual Jordan Peterson lecture long, you should not be looking more than a single hundred MB, let alone a gigabyte. So, clearly less than 2GB.

For a quick math let's assume a character line actually being 3 textual lines long with 100 symbols per line.
That's 300 symbols.
Let's set 4 bytes per symbols for the unicode (if your game is english only, it could by single ASCII byte)

300 times 4 times 20000 equals 24 000 000.

You've read it right.
Less than 24 MiB.

And who says, you can't split the file to load only half of it at time. Or load only partially through some buffer tricks.

Anyways, the answer is you wouldn't even need 200MB. But feel free to allocate as many as you need to freely develop the game.

Make it right first, make it fast later.
>>
>>106742220
I’ll tell you this

there’s going to be a super secret gun in the game that shouts spaghetti

and no one else is working on it expect me
>>
>>106742016
>>106742337
Also consider splitting by act or some large event. you could load it all the dialogue at the start and have it ready for all the characters and the scenes in the act.
>>
>>106742016
>making a game
>can't calculate how much space 20,000 lines of text would take
the absolute state
>>
>>106742140
>1 character = 1 byte
The world has moved beyond ASCII. However, only supporting English is based.
>>
>>106742016
>20,000 lines of dialogue
can do it on 8bit + floppy 640kb
>>
>>106742835
let them be man
>>
>>106742844
localization is pointless if no one will play your game anyway
>>
>>106742016
that's enough for 20,000 lines that are over 100,000 characters long each
>>
>>106742016
>I did it this way because it’s faster than using a dictionary.
They're both so fast you won't notice the "delay" at all. Use a dictionary, or some other method, but not an array.
>>
>>106742016
how about run & check it in Task manager?
Why do anon's count symbols, when we live in the world, where programs store tons of useless code and information?
>>
>>106742016
>2gb ram
you really shouldn't be running anything less than 64gb
>>
>>106742016
>I could load the dialogues only when they need to be displayed, but that might cause the game to pause for a second or two, which could break the vibe.
The right way to do it is to find a way to detect when a dialog is likely to be displayed (for example by level, by proximity to the character etc) and load them/unload them dynamically with a priority queue. Do you think GTA games load the whole thing in memory? No. Streaming has been a thing since the PS2 at least (can't remember any particular PS1 game with streaming but I'm sure there were some).
>>
>>106742016
20,000 lines of dialogue is on the low end of eroge games tbf.
>>
>>106742016
Yes, 20,000 lines of dialogue should be measured in a few megabytes at most, even fewer if compressed.
>>
>>106744787
>>106742016
If each line is roughly the length of a PS1 JRPG textbox, I think you're looking at 18 MiB of uncompressed ASCII.
>>
Why would you load the whole text
Can't you just load the text depending on the zone or something?
>>
20,000 lines, if they're say 100 characters each, is less than 2MiB



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.