Rock, Paper, Scissors
Introduction • Game Rules • Features • Prerequisites • Installation & Building • Usage • Project Structure • License
This is a classic game of Rock, Paper, Scissors, implemented as a command-line application in C with a focus on a modular code structure. The player competes against a computer opponent that makes a random choice. The project demonstrates a clean separation of concerns between game logic, user interface, and utility functions.
The goal is to choose a move that defeats the opponent's move.
- 🗿 Rock beats Scissors (by breaking them).
- ✂️ Scissors beats Paper (by cutting it).
- 📄 Paper beats Rock (by covering it).
If both players choose the same move, the round is a draw.
- Classic Gameplay: A complete implementation of the core Rock, Paper, Scissors rules.
- Player vs. AI: Compete against a computer opponent with a randomized move selection.
- Score Tracking: The game keeps track of the score throughout the session.
- Replayable Rounds: The ability to play again and again without restarting the program.
- Modular Design: The source code is well-structured and separated into:
game_logic: Handles the core game rules.ui: Manages all user input and output.utils: Provides helper functions (e.g., parsing "yes/no" responses).
- Localized UI: The user interface is presented in Russian, demonstrating how localization can be implemented.
- Robust Input: User input is validated to prevent errors.
To build and run this project, you will need:
- A C compiler (e.g., GCC)
- The Make utility
The installation and build process is straightforward:
-
Clone the repository:
git clone https://github.com/b1sted/rock-paper-scissors.git cd rock-paper-scissors -
Compile the code:
make
This command will:
- Compile all source files from the
src/directory. - Place the intermediate object files (
.o) in theobj/directory. - Create the final executable
rps_gamein thebin/directory.
- Compile all source files from the
-
Clean the project (optional):
make clean
This command removes the
obj/andbin/directories along with all build artifacts.
After a successful build, run the game using the following command:
./bin/rps_gameThe program will display a welcome message and the rules. You will then be prompted to make your move by entering the corresponding number.
Сделайте ваш выбор:
1 - Камень
2 - Ножницы
3 - Бумага
0 - Выход
Ваш ход:
After each round, the result and updated score will be displayed, and you will be asked if you want to play again. To exit the game, enter 0 at the move selection menu or answer "no" when asked to continue.
rock-paper-scissors/
├── bin/ # Executables (created by make)
│ └── rps_game
├── obj/ # Intermediate object files (.o) (created by make)
├── include/ # C header files (.h)
│ ├── game_logic.h # Interface for the game logic module
│ ├── rps.h # Core types (Choice) and string representations
│ ├── ui.h # Interface for the user interface module
│ └── utils.h # Interface for the utility module
├── src/ # C source files (.c)
│ ├── main.c # Entry point and main game loop
│ ├── game_logic.c # Implementation of the game logic
│ ├── rps.c # Implementation of functions for the Choice type
│ ├── ui.c # Implementation of all I/O functions
│ └── utils.c # Implementation of utility functions
├── .github/ # GitHub specific files
│ └── assets/
│ ├── logo.png
│ └── screenshot.png
├── .gitignore # Git ignore file
├── LICENSE # MIT License file
├── Makefile # Build script for make
└── README.md # This file
This project is licensed under the MIT License. See the LICENSE file for details.

