Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manavalan2517/memory-game-python
https://github.com/manavalan2517/memory-game-python
memory-game memory-game-python py python
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/manavalan2517/memory-game-python
- Owner: Manavalan2517
- Created: 2024-05-13T09:07:23.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-11T04:43:58.000Z (5 months ago)
- Last Synced: 2024-10-12T09:22:26.861Z (27 days ago)
- Topics: memory-game, memory-game-python, py, python
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
###
# Memory Game Python Script Breakdown
## 1. Importing Necessary Modules
- **random**: for generating random numbers.
- **tabulate**: for formatting the grid display.
- **os**: for clearing the console.## 2. Defining Global Variables
- **values**: a dictionary mapping letters to their corresponding indices in the grid.
- **temp_found**: a list to store the numbers temporarily found during each turn.
- **user_values**: a list to store the user's input for each turn.
- **user_choices**: a list to keep track of the tiles already uncovered by the user.
- **progress**: a boolean flag to indicate whether the game is still in progress.
- **competed**: a boolean flag to indicate whether the game has been completed.## 3. Taking User Input for the Grid Size
- The user is prompted to enter a choice for the grid size (e.g., 2 for a 2x2 grid, 4 for a 4x4 grid).
- The input is validated to ensure it is an even number.## 4. Defining Functions
- **game_elements(num)**: a function that generates the grid elements. It creates a list of random numbers and shuffles them to create pairs.
- **game_process(num)**: a function that handles the game logic. It displays the grid, prompts the user for input, and updates the grid based on the user's choices. It also checks for matches and updates the game status accordingly.## 5. The Main Game Loop
- The main list is populated with the grid elements using the `game_elements` function.
- The `game_process` function is called to start the game.
- After each game, the user is prompted to choose whether to play again.
- If the user chooses to quit, the loop breaks.**Overall, the selected code provides a complete implementation of the memory game with user interaction and grid display.**
###