FLAMES is a name-based game used for entertainment to predict a relationship between two people. The game works by removing common letters from both names, counting the remaining letters, and using that count to eliminate letters from the word FLAMES until a single relationship remains.
Example:
Input: Player 1 name: ADRIAN
Player 2 name: ELOISE
Output: Relationship status - Friends
Working of the FLAMES Game
This project demonstrates string manipulation, list operations, loops and basic game logic in Python.
- Take Two Names as Input: The names are converted to lowercase and spaces are removed.
- Remove Common Letters: Matching characters are removed from both names.
- Count Remaining Letters: The total number of unmatched characters is calculated.
- Initialize FLAMES List: A list containing Friends, Lovers, Affection, Marriage, Enemies, and Siblings is created.
- Eliminate Options: Relationship options are removed in a circular manner using the remaining letter count.
- Display the Result: The last remaining option represents the predicted relationship.
Game Rules
- Take the names of two players as input.
- Remove all common letters from both names, including their repeated occurrences.
- Count the total number of letters left after removing the common ones.
- Use this number to eliminate letters one by one from the list ["F", "L", "A", "M", "E", "S"].
- Keep removing letters in a circular manner (start again from the beginning if the end is reached).
- The last letter remaining in the list shows the predicted relationship between the two players.
Implementation
This program removes common letters from two names and uses the remaining letter count to eliminate options from the FLAMES list in a circular way until one relationship remains.
def rm_common(a, b):
for i in range(len(a)):
for j in range(len(b)):
if a[i] == b[j]:
char = a[i]
a.remove(char)
b.remove(char)
return (a + ["*"] + b, True)
return (a + ["*"] + b, False)
if __name__ == "__main__":
# Take player names as input
n1 = list(input("Player 1 name: ").lower().replace(" ", ""))
n2 = list(input("Player 2 name: ").lower().replace(" ", ""))
# Validate input
if not n1 or not n2:
print("Please enter valid names.")
exit()
# Remove common characters
cont = True
while cont:
lst, cont = rm_common(n1, n2)
idx = lst.index("*")
n1 = lst[:idx]
n2 = lst[idx + 1:]
# Count remaining letters
cnt = len(n1) + len(n2)
# FLAMES relationship list
res = [
"Friends",
"Lovers",
"Affectionate",
"Marriage",
"Enemies",
"Siblings"
]
# Eliminate relationships until one remains
while len(res) > 1:
split_index = (cnt % len(res)) - 1
if split_index >= 0:
right = res[split_index + 1:]
left = res[:split_index]
res = right + left
else:
res.pop()
# Display result
print("Relationship status:", res[0])
Output
Player 1 name: NATHANIEL
Player 2 name: ISABELLA
Relationship status: Marriage
Explanation:
- Define rm_common() Function: Finds and removes matching characters from both name lists.
- Process Input: Converts the names to lowercase, removes spaces, and stores them as character lists.
- Remove Common Letters: A while loop repeatedly calls rm_common() until no common characters remain.
- Count Remaining Characters: The cnt variable stores the total number of unmatched letters.
- Initialize FLAMES List: The res list contains the six possible relationship outcomes.
- Apply Elimination Logic: List slicing and the remaining character count are used to eliminate entries until one option remains.