Renpy npc schedule system advice

despiteful

COED Conquest Dev
Game Developer
Jun 12, 2020
330
625
Hello dear forum users.

Im currently creating a dating sim type game in renpy. Im a beginner in regards to programming outside basic univercity lectures so im not completely unable, but getting good performance in the game is something that is very hard for me to estimate, which brings me to my problem:

In my game different locations are only available on different days/daytimes/seasons etc.
The same is true for the location of characters .

My plan was to create a csv for every place, character(multiple since behaviour changes with affection etc).

And that brings me to my question, if i load every csv as a list at the beginning of the game that sounds like a giant waste of ressources considering i only need a single value per entity and gameplay loop (even less since i dont need to check sublocations if the player doesnt even go there)

So should i read the csvs at the beginning of every gameplay loop? is this super slow? How can i read a single element from the csv without loading the whole file into memory?

My current solution would have been to give every place/character a string property that responds to a csv file.
And read it in a function temporarely into memory return the single value and do this for every character at the start of every gametimechange(so my gameplay loop)

Any advice for me?
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,976
16,231
In my game different locations are only available on different days/daytimes/seasons etc.
The same is true for the location of characters .
You are talking about how many locations, how many days/daytimes/seasons/etc and how many characters ?
Are the locations available following a regular pattern (all weeks of a given season are the same) or not ?


My plan was to create a csv for every place, character(multiple since behaviour changes with affection etc).
And to load them into what structure ?


My current solution would have been to give every place/character a string property that responds to a csv file.
And read it in a function temporarely into memory return the single value and do this for every character at the start of every gametimechange(so my gameplay loop)
In one hand, there's your data, that should take few MB of RAM at most, but more surely few hundreds of KB or perhaps even less, which is nothing at all nowadays.
On the other hand, there's your CSVs that you'll load, then proceed to keep only a part of them, every now and then, which will easily take at least one second, if not few seconds, each time the in-game clock will advance.

I'm not sure that the second option is really the best one.


Any advice for me?
Since you just have a basic scholar knowledge in regard of codding, my first advice is to start with a smaller project.
It will offer you the possibility to slowly learn how to use Ren'py, how to deal with more or less complex data structures, and how to write a game. This while understanding how Ren'py react and how to optimize it. Then, once you'll have finished this first game, and acquired this knowledge, to start this big project.

As for my second advice, it's a classical : Optimization should never be your first step.
First you make your code works, then you make it bug free, and only when this is done, you think about it's optimization.
 
  • Like
Reactions: JohnDupont

SerokMinmas

Newbie
Sep 6, 2016
54
74
You should really have absolutely no issues loading the entire schedule once at the beginning of the game forgetting about it and just RAM-access it when you need, its going to be really tiny.

Just think about how many lines of text you can store into extremely tiny amounts of memory, 100kb of RAM can hold 100*1024 individual characters if you dont take multi-char encoding into account, and CSVs are just plain-text.

AND RAM accessing is always faster then Disk accessing so thats a plus too.
 

despiteful

COED Conquest Dev
Game Developer
Jun 12, 2020
330
625
Thx, you are of course right, loading even 100 lists is basically 0 resources.
I will now just read the csv into a list at the start and be done with it

and anne thx to you too, i currently really struggle with wanting to do everything at the same time.
I made myself now a diagram with an order in which i have to create which classes etc to not stress myself too much :)
Regarding starting smaller, thats not really an option, since i dont want a classic VN, and making one would probably increase the chances i drop the project.
However, i did strip it done to the barebones my game has to have, and if that works i continue to add to it.
 

DuniX

Well-Known Member
Dec 20, 2016
1,238
826
Text is Free.
Text wants to be Free and swim freely in the RAM.
The only thing you should keep in mind is when you are spawning,initializing stuff or adding references procedurally as that can blow up fast if you are not careful.
 

parantres

New Member
Jun 10, 2020
5
0
There is no need to declare the data in a csv and parse that in renpy. You can just write it as a python dictionary, in its own file and import it into renpy. It will be easier to edit for you and renpy can use it directly without parsing.