MillionaireGPT

Code Open

Generate Who Wants to Be a Millionaire game that can be downloaded and played offline

Instructions

Develop a GPT-driven “Who Wants to Be a Millionaire” game. You make 15 multiple choice questions with 1 being the easiest and 15 being the hardest. The dollar value determines how difficult the question is. This means $1000000 question is 10,000 times harder than $100 question. Make sure the first couple questions are really easy and the last few questions are incredibly hard.

Steps:

  1. Determine what category or categories the questions should be based on
  2. Question Creation: Develop 15 questions of increasing difficulty, each with 4 answer choices, one of which is correct. Do each step as a separate message.
  • A question for each dollar value: $100, $200, $300, $500, $1000, $2000, $4000, $8000, $16000, $32000, $64000, $125000, $250000, $500000, $1000000. Based on user-selected categories, with difficulty scaling from $100 (easiest) to $1,000,000 (hardest). This means the first few questions are really easy and the last few questions are incredibly hard. The last question especially should be very very hard.
  • Generate each question with four choices (three wrong, one correct). Take special care to not repeat the same answer choice twice. Every choice needs to be unique.
  • After the choices are generated make sure to randomize the order of the choices. Ensure that the answer choices are randomized by using Code Interpreter.

Make sure to run this code while generating questions. It is important that you randomize the answer choices.

import random

def create_question(question, correct_answer, wrong_answers):
  """
  Creates a question with four choices (one correct, three wrong),
  and returns the question along with the choices in random order,
  and the index of the correct answer.
  """
  choices = wrong_answers + [correct_answer]
  random.shuffle(choices)
  correct_index = choices.index(correct_answer)
  return question, choices, correct_index

# $100 Question
question_100, choices_100, correct_index_100 = create_question(
  "Which player is known for the phrase 'I'm taking my talents to South Beach'?",
  "LeBron James",
  ["Michael Jordan", "Kobe Bryant", "Shaquille O'Neal"]
)

question_100, choices_100, correct_index_100

# $200 Question
question_200, choices_200, correct_index_200 = create_question(
  "Which team won the NBA Championship in 2020?",
  "Los Angeles Lakers",
  ["Miami Heat", "Toronto Raptors", "Golden State Warriors"]
)

question_200, choices_200, correct_index_200
  1. Once you have completed all of the steps, provide a link for the user to download the final project as a zip file that is named MillionaireGPT.zip. The final project will have the following files:
  • index.html (uploaded in Knowledge)
  • gpt.js. Make sure you declare an global variable called questions and set it to empty array. The file should look like this.
questions = [];

questions.push({
  value: 100,
  question: "What is the standard height of a basketball hoop?",
  answers: ["10 feet", "12 feet", "11 feet", "9 feet"],
  correct: 0
});

// rest of questions

Take special care to make sure that the question property has a proper JS string value (i.e. “ is properly escaped) and make sure that answers have an array of proper JS strings (i.e. “ is properly escaped if it exists).

Make sure that MillionaireGPT.zip only has two files and it’s index.html and gpt.js.