A command-line trivia game where two players can compete against each other by answering multiple-choice questions from various categories.
- Python 3.x installed on your system
- Basic familiarity with running commands in terminal/bash
- Clone or download this repository
- Navigate to the project directory:
cd path/to/trivia-game- Run the game with default settings:
python main.pyThis will start a game with default player names and questions from the demo question set.
The game comes with three optional extensions that can be enabled:
- Category Choice (--ext1): Players can choose question categories
- Score Variation (--ext2): Points vary based on question difficulty
- Lifelines (--ext3): Players get helpful lifelines during the game
python main.py [options]
Options:
--questions_file FILE Path to custom questions JSON file (default: demo_questions.json)
--player1 NAME Name for Player 1 (default: "player 1")
--player2 NAME Name for Player 2 (default: "player 2")
--ext1 Enable category choice extension
--ext2 Enable score variation extension
--ext3 Enable lifelines extension- Basic game with custom player names:
python main.py --player1 "Alice" --player2 "Bob"- Game with all extensions enabled:
python main.py --ext1 --ext2 --ext3- Using a custom questions file:
python main.py --questions_file my_questions.jsonYou can create your own questions file following the format in demo_questions.json. The file should contain an array of questions with the following structure:
{
"questions": [
{
"type": "multiple",
"difficulty": "easy|medium|hard",
"category": "Your Category",
"question": "Your question text?",
"correct_answer": "Correct option",
"incorrect_answers": [
"Wrong option 1",
"Wrong option 2",
"Wrong option 3"
]
}
]
}Requirements for questions file:
- Must contain an even number of questions
- At least 2 questions are required
- Each question must follow the format above
- Players take turns answering questions
- Each correct answer earns points
- With score variation (--ext2), points depend on difficulty:
- Easy: 1 point
- Medium: 2 points
- Hard: 3 points
- The player with the most points at the end wins
- Use the category choice extension (--ext1) for more strategic gameplay
- Enable lifelines (--ext3) to make the game more exciting
- Create your own questions file to customize the experience
- Make sure your questions file has an even number of questions
If you encounter errors:
- Verify your Python version is 3.x
- Check that your questions file follows the correct JSON format
- Ensure your questions file has an even number of questions
- Make sure all required files are in the same directory