Randomize 100 strings and organize them for later choices

Hello, I am working on releasing my first commercial game, and it consists of reading other people’s stories. I would like to ask advice on what would a good way be to accomplish the following objectives:

-Have a big file with many strings that hold the stories (they are about 30 sentences long)
-At each game start, randomize 100 picks for that game session, but never repeat the same string twice (giving id or excluding them somehow??)

I originally thought I could make an array of strings, but I don’t know if that would pose any problems regarding performance , as it is the bulk of the game. The main idea is the following:

-Each story has an emotion, the player selects the emotion behind each story, so we need to keep account of that, as it can lead to outcomes based on true or false values.

So my initial thought would be:

-Have a text file with all the stories
-Randomize, INGAME, 100 strings attached to a game object
-Each stone holds an emotion check, that works together with the UI in order to have the outcome

Since arrays cannot be resized, I was thinking of using string lists or dictionaries, but I have not used them ever before. What would your simple approach be? Thank you!

Create a new List of string StoryList. Add every string to this list.

Create another list of string RandomList and while your first StoryList still has content, generate a random index from StoryList size add it to the RandomList, and remove it from the StoryList.

1 Like

That gives me a lead, thank you! Any idea abiyt ghow could I go about making sure the stories are sorted with the corresponding emotion behind them?

How many times are you doing this sorting? This sounds like something you would just do once at the beginning of the game and not touch again. If so, performance doesn’t really matter.

If you wanted to make sure you knew which strings are tied to which emotions, you could just create a separate List for each emotion, and put them in the corresponding one when you remove it from the main List.

2 Likes

When you are doing your list shuffle, alongside you attach the emotion data and move it to a new list in the same way sorry I didn’t post reply was written. I guess I was wondering why you didn’t figure it out O.o

1 Like

Probably had to do with me not sleeping haha, I did figure it out in the morning. Thanks!