Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Make a website of the game "20 questions"

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Amazon Novaamazon.nova-pro-v1:0’s answer.
  1. User

    Make a website of the game "20 questions"

  2. Assistant

    Here’s a simple, self-contained “20 Questions” web app in plain HTML/CSS/JavaScript.
    Player 1 thinks of an object; Player 2 types yes/no questions; Player 1 answers; the app keeps track of count and Q&A history.

    Save the following as index.html and open in your browser:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>20 Questions Game</title>
      <style>
        body {
          font-family: Arial, sans-serif;
          background: #f0f8ff;
          color: #333;
          display: flex;
          flex-direction: column;
          align-items: center;
          padding: 20px;
        }
        h1 {
          margin-bottom: 5px;
        }
        #instructions {
          margin-bottom: 20px;
          text-align: center;
        }
        #game {
          width: 100%;
          max-width: 500px;
          background: #fff;
          border-radius: 8px;
          padding: 20px;
          box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }
        #question-form {
          display: flex;
          margin-bottom: 10px;
        }
        #question-input {
          flex: 1;
          padding: 8px;
          border-radius: 4px;
          border: 1px solid #bbb;
          margin-right: 8px;
        }
        #ask-btn {
          padding: 8px 12px;
          border: none;
          background: #007bff;
          color: white;
          border-radius: 4px;
          cursor: pointer;
        }
        #ask-btn:disabled {
          background: #ccc;
          cursor: not-allowed;
        }
        #answers {
          margin-bottom: 10px;
        }
        #answers label {
          margin-right: 12px;
        }
        #history {
          max-height: 250px;
          overflow-y: auto;
          border-top: 1px solid #eee;
          padding-top: 10px;
        }
        .entry {
          padding: 6px 0;
          border-bottom: 1px dashed #eee;
        }
        #reset-btn {
          margin-top: 15px;
          padding: 8px 12px;
          border: 1px solid #007bff;
          background: white;
          color: #007bff;
          border-radius: 4px;
          cursor: pointer;
        }
      </style>
    </head>
    <body>
      <h1>🔎 20 Questions</h1>
      <p id="instructions">
        Player 1: Think of an object.  
        Player 2: Ask up to 20 yes/no questions to guess it!
      </p>
    
      <div id="game">
        <div id="status">Questions left: <span id="left">20</span></div>
    
        <form id="question-form">
          <input type="text" id="question-input" placeholder="Ask a yes/no question…" required />
          <button type="submit" id="ask-btn">Ask</button>
        </form>
    
        <div id="answers" style="display:none;">
          <label><input type="radio" name="answer" value="Yes" required /> Yes</label>
          <label><input type="radio" name="answer" value="No" /> No</label>
          <label><input type="radio" name="answer" value="Maybe" /> Maybe</label>
          <button id="record-btn">Record Answer</button>
        </div>
    
        <div id="history"></div>
        <button id="reset-btn">🔄 Reset Game</button>
      </div>
    
      <script>
        const MAX_Q = 20;
        let remaining = MAX_Q;
        let currentQuestion = '';
    
        const leftEl = document.getElementById('left');
        const form = document.getElementById('question-form');
        const qInput = document.getElementById('question-input');
        const askBtn = document.getElementById('ask-btn');
        const answersDiv = document.getElementById('answers');
        const recordBtn = document.getElementById('record-btn');
        const historyEl = document.getElementById('history');
        const resetBtn = document.getElementById('reset-btn');
    
        function updateStatus() {
          leftEl.textContent = remaining;
          if (remaining <= 0) {
            askBtn.disabled = true;
            qInput.disabled = true;
            answersDiv.style.display = 'none';
            alert("❗ No questions left. Game over. Reset to play again!");
          }
        }
    
        form.addEventListener('submit', e => {
          e.preventDefault();
          if (remaining < 1) return;
          currentQuestion = qInput.value.trim();
          if (!currentQuestion) return;
          // Show answer controls
          answersDiv.style.display = 'block';
          askBtn.disabled = true;
          qInput.disabled = true;
        });
    
        recordBtn.addEventListener('click', () => {
          const ans = document.querySelector('input[name="answer"]:checked');
          if (!ans) return alert("Pick an answer!");
          const entry = document.createElement('div');
          entry.className = 'entry';
          entry.textContent = `Q${MAX_Q - remaining + 1}: ${currentQuestion} — ${ans.value}`;
          historyEl.appendChild(entry);
    
          // reset for next
          remaining--;
          updateStatus();
          qInput.value = '';
          qInput.disabled = false;
          askBtn.disabled = false;
          answersDiv.style.display = 'none';
          ans.checked = false;
        });
    
        resetBtn.addEventListener('click', () => {
          remaining = MAX_Q;
          currentQuestion = '';
          historyEl.innerHTML = '';
          qInput.value = '';
          qInput.disabled = false;
          askBtn.disabled = false;
          answersDiv.style.display = 'none';
          updateStatus();
        });
    
        // init
        updateStatus();
      </script>
    </body>
    </html>
    

    How it works

    1. Player 1 thinks of something.
    2. Player 2 types a yes/no question and clicks “Ask”.
    3. Player 1 selects “Yes/No/Maybe”, clicks “Record Answer”.
    4. The Q&A is logged, and the remaining count decrements.
    5. After 20 questions the game ends; hit “Reset Game” to start over.

    Feel free to enhance:

    • Add styles or animations
    • Persist history in localStorage
    • Let the app itself try to guess using a small decision tree.

    Enjoy! 🎮

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.