Toma400 / The_Isle_of_Ansur

Python-based text RPG game, successor of Between Shadows and Light.
Other
9 stars 0 forks source link

`parseGender` improvements #121

Open Toma400 opened 2 months ago

Toma400 commented 2 months ago

I'm really rusty on my old code (and IoA seems to be permanently in such state) but I'm wondering if the code made to parse text and replace its default M format couldn't be coded better? My concern is mostly accuracy and performance:

Just some concerns I had over few days and which should be adressed for this feature to be actually good and not something really hitting game's performance (as if it wasn't terrible already)


I went over the code and I'd say current code check may still have performance advantages over solely parsing first letter from text, or at least the cost difference is minimal (worth checking whether text[0] == "" is performant because it checks precise element, or not, because it parses whole string? just me spitballing).

Toma400 commented 2 months ago

Idea partially taken from Reddit post I made on the topic - what if gender wasn't based on dictionary, but instead work similarly to how _descr works? I imagine this working like that:

regular_key^gender

Game would first look for gendered version, and if not found, it would search for just regular key. For example:

"test" = "Look at the player! He is such a lovely person"
"test^female" = "Look at the player! She is such a lovely person"
"test^non_binary" = "Look at the player! They are such a lovely person"
"test2" = "This is good day to kill some orcs"

In this example, test would adjust itself to all standard genders, while test2 would just aim to regular key. Minimum amount of parsing or checks, performance is happy. I'd also brainstorm if parseGender check is still needed - I guess it's a bit less perf heavy than iterating over keys, so I guess keeping it would be useful.

Issues I could see:

Neither really serious though.