Hi, as always I post here a question I have to warn that english is not my main language.
I am using Elixir for developing games, specifically my game is a “Guess the flag”, the game shows you a flag and gives you four options, one is (of course) the right one and the other three are the distractors or the wrong answers.
When I thought about the design of the game, I decided not to use a DB, but use different Agents holding the list of the possible answers (kept in json files), and when a player plays a new round of the game, the main process sends a message to each one of the Agents and they reply back with the distractors and with the correct answer, and the main process build the list of possible options.
My question is, is this a good pattern… I mean holding a list of words in each Agent and query them?.
It’s a game of guessing the correct “door”, there are four “doors” where one is the “correct” one and the remaining are “false.” The guesser can pick one “door” and the game will end if the “door” is not the correct one.
When a new round start the game process will send a state to each of the processes representing the doors. When the user pick a door the manager ask the door if it is the correct one and it will reply.
If this is the case I think that a list stored in the manager process would be sufficient; even just storing a number between 1 and 4, or how many you need—or should the processes hold more information/state than wether they are the correct door or not?
I will try to explain my best the procedure of a round
When the player start a game, round one is sent to the player, the round is composed of a image of a flag, and four country names… one is the correct and the other three not.
I thought getting the three wrong options from three differents list of words, that will be in three different Agents, and the way of getting each one is sending a message asking for a random value of each list.
One more question, if the list of counties gets bigger (maybe with 100.000 entries between countries and another types of flags, thinking in different levels of difficulty), using shuffle is better than three paralell randoms in three lists of 33.333?
Okay, 100_000 entries, then we have a different kind of beast
You could shuffle once on initialisation, and just take from the top like you would with a deck of cards and store the rest as the state for the next round. Then you would only have to do the heavy operation of shuffling once—shuffling is not a problem for small lists, but if you do it all the time for bigger you might get into trouble performance wise.
I don’t know about the different levels of difficulties.
I will try with this way, sorry for the bad english… when I said about differente levels of difficulty I mean that I will add a lot of another flags (think of Red Cross and like that) this is the explanation of why it will grow near 100.000