Welcome to Quizzy, a real-time multiplayer quiz game implemented in Java. Challenge your friends or compete against random opponents in this exciting trivia adventure! Quizzy utilizes Java Datagram and Socket classes to establish a TCP connection between the server and client programs, ensuring smooth communication between players.
- Server-Client Architecture: We use Transmission Control Protocol (TCP) for Quizzy to ensure that the messages are relayed efficiently and reliably between the players and the server. TCP is a standard that defines how to establish and maintain a network conversation. Some of the key features of TCP are (1) Reliability, (2) Ordered delivery, (3) Flow control, and (4) Connection-oriented. This was implemented using Socket class in Java.
- Real-time multiplayer gameplay.
- Multiple-choice trivia questions.
- Multithreading for efficient management of multi-player function (using Thread class).
- Timer functionality to effectively manage the timeline of the game like waiting for players to answer, waiting for the Server to send score to players, and some other (using sleep method in Thread).
- Synchronized functions to ensure data consistency in a multi-threaded environment (using Java synchronized method).
- Handle different types of messages in Client program, categorized by adding a character before each message like “q” for question message, “s” for score message, “w” for welcome message, and “r” for result message.
- The Server sends different types of messages including welcome message, questions, scores, and result. Perform answer checking, score recording, and create results based on players' scores.
- Handle Timeout when the server doesn’t receive an answer from players (clear buffer reader after each question).
- The Server will randomly pick questions.
- Add Host role to game. A host can select question topics, number of questions, and time allowed for each question.
- Quizzes Generation: We use the ChatGPT API (OpenAI, n.d.) to generate quizzes based on a specific topic, number of questions, and difficulty level. (We created functions for this but haven’t integrated to the game yet)
To run Quizzy on your local machine, follow these steps:
- Clone the Quizzy repository.
- Compile the Java source files using your preferred Java compiler.
- Run the server program on one machine.
- Run the host program on another machine to set up game.
- Run the client program on multiple machines to join the game.
- Launch the Server program (java network/Server).
- Launch the Host program (java network/Host) to set up game.
- Launch the Client program on different machines or on different terminals (java network/Client).
- Wait for other players to join.
- Once the game starts, answer the trivia questions within the allotted time.
- Earn points for each correct answer.
- The player with the highest score at the end of the game wins.