Simple FLAMES game in Python
Python is a programming terminology that serves multiple purposes for programmers to perform any activity well. Python can besides be utilized for game development. In the follow tutorial, let us build a simple FLAMES game without using any external game libraries such as PyGame .
But before we get started, let us briefly understand what the FLAMES game is .
What is the FLAMES game?
FLAMES is a game named after the abbreviation : Friends, Lovers, Affectionate, Marriage, Enemies, Siblings. It is a celebrated game among young girls at sleepovers, specifically with pre-teens and teens who are starting to explore the world of crushes. This game does not precisely predict whether an individual is perfect for person or not ; however, it can be fun to play with friends .
How to Play the FLAMES game?
The FLAMES game is originally played on newspaper. therefore, the general necessity for this game is a pen/pencil and wallpaper. however, we will be playing this game on Computer. thus, the method of playing involves the follow steps :
STEP 1: Take two names
We will start by writing two names. For exercise, we will use “ LOID FORGER ” and “ YOR FORGER ” .
STEP 2: Cancel out the common letters in both names
We will immediately cancel out the common letters in both the names irrespectively of the shell in which the letters are written. Note that we only have to cancel out an example of the letter in both names, not all instances of the letter .
In the above model, we will get “ LID ” & “ year ” from “ LOID FORGER ” & “ YOR FORGER ”. As we can observe, we have eliminated the common letters – O, F, O, R, G, E, and r from both the words .
STEP 3: Count the count of remaining letters
once we eliminate all the common letters, we will count the remaining letters in both names .
In the above model, we will combine the uncancelled letters and get – “ LIDYR ” and count the entire letters in the word. As a solution, we get 5 .
Step 4: Compare the number to the acronym FLAMES and remove letters consequently .
We will now start assigning each numeral to each letter in the acronym, like 1 to F, 2 to L, 3 to A …, till we get to that count. Counting is done in anti-clockwise circular fashion. If we get to the goal of the acronym, we restart the buffet till we get to the number. For example, 6 to S, so 7 will begin at F again until we get to the end of the total .
once we get to the end, we will remove that letter and restart the count until we get entirely one letter left. We will then compare the consequence with the following table :
Let us now consider implementing the above exercise and compare the act we got to the acronym FLAMES .
There is a total of 5 letters present in the news. We will start the consider from F ; E is at the one-fifth count, so we will eliminate E and begin the count again ; however, at this time, we will start from S .
now, M is at the fifth count, so we will eliminate M and begin counting from S.
S is at the one-fifth count, so we will eliminate S and begin counting from F .
L is at the fifth consider, so we will eliminate L and begin counting from A .
A is at the fifth count so we will eliminate A. We have only one letter remaining ; thus, this is the concluding suffice .
Hence, the relationship is F, i, Friends .
Implementation of FLAMES game in Python
We will accept two names as input signal and then remove the park characters with their respective coarse occurrences. To remove, we will create a user-defined function that will store a list of characters of two players ‘ names respectively and return a list of concatenate lists. Once we remove all the common characters, we will count the total number of remaining characters and create a consequence list with FLAMES acronym, i.e., [ “ Friends ”, “ Lovers ”, “ Affectionate ”, “ marriage ”, “ Enemies ”, “ Siblings ” ]. We will then begin removing discussion after password until the list is left with only one word, with the assistant of the count we got. The discussion which remains in the list will be the result .
Let us now consider the following snip of code demonstrating the lapp :
In the above snip of code, we have defined a serve as eliminateCommonChars() to remove common characters with their respective occurrences. This function accepts two lists as its arguments. We have used two for -loops within this function to iterate through these lists. We have then checked if any common character is found. We have then removed that fictional character and returned the tilt of concatenate lists with True Flag. If no common characters are found, another concatenate list is returned with a False Flag. We have then defined the independent officiate that accepts users ‘ names and converts them into lower character, replacing any space with an empty bowed stringed instrument and making a list of letters or characters. We have then assigned an initial flag as True. We have then used the while loop and called the eliminateCommonChars() affair until common characters are found or keep loop until continue flag is True. We then counted the full remaining letters in the tilt and created another list as res consist of the FLAMES acronym. We used the while closed circuit again and kept looping until entirely one item was left in the res tilt. We have besides stored the index value from where we have to perform slicing. To perform anti-clockwise circular fashion consider, we have to check if the separate index is greater than or adequate to zero. At last, we have done tilt slicing and number concatenation and printed the result .
Let us now save this Python file and execute the follow instruction in the command blast or end and see the output signal :
First Player Name : LOID FORGER Second Player Name : YOR FORGER Relationship status : Friends
First Player Name : STEVE ROGERS Second Player Name : PEGGY CARTER Relationship status : Lovers