Farrier

openai discworld trivia game in Java

Dec 25th, 2022 (edited)
1,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.21 KB | Gaming | 0 0
  1. /*
  2. Me: In a different random language, write a trivia game about the Discworld in 50 lines or less.
  3. OpenAI: Here is a randomly-selected programming language: Java. And here is a trivia game about the Discworld written in Java in 50 lines or less: [Code below]
  4. OpenAI: This code defines an array of trivia questions and answers, and then presents each question to the user, allowing them to enter their answer. The code then checks the user's answer and increments their score if it is correct. At the end, the code displays the user's final score.
  5.  
  6. Me: what are some more questions you could add to the java one?
  7. OpenAI: Here are some additional questions that could be added to the Discworld trivia game written in Java:
  8.     Who is the Discworld's equivalent of the god Odin?
  9.     Who is the Discworld's equivalent of the god Thor?
  10.     Who is the Discworld's equivalent of the god Loki?
  11.     Who is the Discworld's equivalent of the god Dionysus?
  12.     Who is the Discworld's equivalent of the god Apollo?
  13.     Who is the Discworld's equivalent of the god Hermes?
  14.     Who is the Discworld's equivalent of the god Mercury?
  15.     Who is the Discworld's equivalent of the god Mars?
  16.     Who is the Discworld's equivalent of the god Venus?
  17.     Who is the Discworld's equivalent of the god Jupiter?
  18.     Who is the Discworld's equivalent of the god Saturn?
  19.     Who is the Discworld's equivalent of the god Uranus?
  20.     Who is the Discworld's equivalent of the god Neptune?
  21.     Who is the Discworld's equivalent of the god Pluto?
  22. OpenAI: To add these questions to the game, they could be added to the questions array in the same format as the existing questions.
  23.  
  24. Me: what would the correct answers be to those questions?
  25. OpenAI: Here are the correct answers to the additional Discworld trivia questions that were listed in the previous response:
  26.     Who is the Discworld's equivalent of the god Odin? -> Odin
  27.     Who is the Discworld's equivalent of the god Thor? -> Thor
  28.     Who is the Discworld's equivalent of the god Loki? -> Loki
  29.     Who is the Discworld's equivalent of the god Dionysus? -> Dionysus
  30.     Who is the Discworld's equivalent of the god Apollo? -> Apollo
  31.     Who is the Discworld's equivalent of the god Hermes? -> Hermes
  32.     Who is the Discworld's equivalent of the god Mercury? -> Mercury
  33.     Who is the Discworld's equivalent of the god Mars? -> Mars
  34.     Who is the Discworld's equivalent of the god Venus? -> Venus
  35.     Who is the Discworld's equivalent of the god Jupiter? -> Jupiter
  36.     Who is the Discworld's equivalent of the god Saturn? -> Saturn
  37.     Who is the Discworld's equivalent of the god Uranus? -> Uranus
  38.     Who is the Discworld's equivalent of the god Neptune? -> Neptune
  39.     Who is the Discworld's equivalent of the god Pluto? -> Pluto
  40. OpenAI: These answers could be added to the game by adding them to the answers array in the same format as the existing answers.
  41.  
  42. Me: I don't think those questions are very relevant to the Discworld. What are some better, more relevant discworld trivia questions and answers that could be added to the program?
  43. OpenAI: Here are some additional Discworld trivia questions and answers that could be more relevant to the series:
  44.     What is the name of the guild of thieves in Ankh-Morpork? -> The Thieves' Guild
  45.     Who is the leader of the Ankh-Morpork City Watch? -> Sam Vimes
  46.     Who is the ruler of Ankh-Morpork? -> Lord Vetinari
  47.     Who is the head librarian of the Unseen University? -> Librarians
  48.     Who is the wizard in charge of the Unseen University? -> Archchancellor
  49.     Who is the Discworld's equivalent of the witchfinder general? -> Granny Weatherwax
  50.     Who is the Discworld's equivalent of the duchess of Borgia? -> Lady Margolotta
  51.     Who is the Discworld's equivalent of the pope? -> The High Priest of Blind Io
  52.     Who is the Discworld's equivalent of the fairy godmother? -> Miss Tick
  53.     Who is the Discworld's equivalent of the three little pigs? -> The Three Little Pigs
  54. OpenAI: These questions and answers could be added to the Discworld trivia game written in Java by adding them to the questions array in the same format as the existing questions.
  55.  
  56. Me: Those are good, but all the questions are quire similar "who is" questions. What would be a better range of varied Discworld trivia questions and answers?
  57. OpenAI: Certainly! Here are some additional Discworld trivia questions and answers that cover a wide range of topics:
  58.     What is the name of the Discworld's equivalent of the planet Earth? -> The Discworld
  59.     What is the name of the Discworld's equivalent of the planet Venus? -> The Discworld
  60.     What is the name of the Discworld's equivalent of the planet Mars? -> The Discworld
  61.     What is the name of the Discworld's equivalent of the planet Jupiter? -> The Discworld
  62.     What is the name of the Discworld's equivalent of the planet Saturn? -> The Discworld
  63.     What is the name of the Discworld's equivalent of the planet Uranus? -> The Discworld
  64.     What is the name of the Discworld's equivalent of the planet Neptune? -> The Discworld
  65.     What is the name of the Discworld's equivalent of the planet Pluto? -> The Discworld
  66.     What is the name of the Discworld's equivalent of the planet Earth, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, and Pluto combined? -> The Discworld
  67.     What is the name of the Discworld's equivalent of the universe? -> The Discworld
  68.     What is the name of the Discworld's equivalent of the Milky Way galaxy? -> The Discworld
  69.     What is the name of the Discworld's equivalent of the Andromeda galaxy? -> The Discworld
  70.     What is the name of the Discworld's equivalent of the Triangulum galaxy? -> The Discworld
  71.     What is the name of the Discworld's equivalent of the Large Magellanic Cloud? -> The Discworld
  72.     What is the name of the Discworld's equivalent of the Small Magellanic Cloud? -> The Discworld
  73. OpenAI: These questions and answers could be added to the Discworld trivia game written in Java by adding them to the questions array in the same format as the existing questions.
  74. */
  75.  
  76. import java.util.Scanner;
  77. import java.util.Arrays;
  78.  
  79. public class DiscworldTrivia {
  80.     public static void main(String[] args) {
  81.         String[][] questions = {
  82.             {"What is the name of the city-state on the Discworld that is known for its bureaucracy?", "Ankh-Morpork"},
  83.             {"What is the name of the Discworld's equivalent of Death?", "Death"},
  84.             {"What is the name of the Discworld's equivalent of the Devil?", "Crimson King"},
  85.             {"What is the name of the Discworld's equivalent of magic?", "The Art"},
  86.             {"What is the name of the Discworld's equivalent of Hell?", "Hell"},
  87.             {"What is the name of the Discworld's equivalent of the sun?", "Great A'Tuin"}
  88.         };
  89.  
  90.         int score = 0;
  91.         Scanner scanner = new Scanner(System.in);
  92.         for (String[] question : questions) {
  93.             System.out.println(question[0]);
  94.             String answer = scanner.nextLine();
  95.             if (answer.equals(question[1])) {
  96.                 System.out.println("Correct!");
  97.                 score++;
  98.             } else {
  99.                 System.out.println("Incorrect.");
  100.             }
  101.         }
  102.         System.out.println("You scored " + score + " out of " + questions.length + ".");
  103.     }
  104. }
  105.  
Tags: openai
Advertisement
Add Comment
Please, Sign In to add comment