The FLAMES Game in Python

Share your love

Let’s create a step-by-step guide for building the classic FLAMES game in Python. FLAMES is a fun game that stands for Friends, Lovers, Affectionate, Marriage, Enemies, Sibling. Although it doesn’t accurately predict relationships, it can be entertaining to play with friends. We’ll implement a simple version of this game without using any external game libraries like PyGame.

1. Game Rules:

  • Take the names of two players.
  • Remove common characters with their respective common occurrences.
  • Count the remaining characters.
  • Use the FLAMES acronym: [“F”, “L”, “A”, “M”, “E”, “S”].
  • Start removing letters using the count obtained.
  • The last remaining letter determines the relationship status.

2. Implementation Steps:

Step 1: Take Input Names

Python

def remove_match_char(list1, list2):
    for i in range(len(list1)):
        for j in range(len(list2)):
            if list1[i] == list2[j]:
                c = list1[i]
                list1.remove(c)
                list2.remove(c)
    list3 = list1 + ["*"] + list2
    return [list3, True]

if __name__ == "__main__":
    player1_name = input("Enter player 1 name: ").upper()
    player2_name = input("Enter player 2 name: ").upper()

AI-generated code. Review and use carefully. More info on FAQ.

Step 2: Remove Common Characters

Python

    names = remove_match_char(list(player1_name), list(player2_name))
    remaining_characters = len(names[0]) - names[0].count("*")

AI-generated code. Review and use carefully. More info on FAQ.

Step 3: Determine Relationship

Python

    flames = ["F", "L", "A", "M", "E", "S"]
    while len(flames) > 1:
        index = (remaining_characters - 1) % len(flames)
        flames.pop(index)
    result = flames[0]

    print(f"Relationship status: {result}")

AI-generated code. Review and use carefully. More info on FAQ.

3. Example:

  • Input:
    • Player 1 name: AJAY
    • Player 2 name: PRIYA
  • Output:
    • Relationship status: Friends

Conclusion:

Written by: Piyush Patil

You’ve successfully created a simple FLAMES game in Python! Feel free to customize it or add more features. Happy coding! 😊

Share your love