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

What is the algorithm used in colour prediction game

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Hunyuanhunyuan-turbos-20250416’s answer.
  1. User

    What is the algorithm used in colour prediction game

  2. Assistant

    Here are the most common ways “colour prediction” (or “Simon-says”-style) games pick the next colour in the sequence:

    1. Pseudorandom-number generator (PRNG)
      • Languages/frameworks all ship with an RNG under the hood (e.g. Mersenne Twister, an LCG or Xorshift).
      • You simply do something like

      // JavaScript example
      const colours = ['red','green','blue','yellow'];
      let next = colours[Math.floor(Math.random()*colours.length)];
      

      • Pros: trivial, fast.
      • Con: not cryptographically secure and may repeat the same colour twice in a row.

    2. Shuffled deck (Fisher–Yates)
      • If you want to avoid immediate repeats or ensure an even spread, you can pre-shuffle an array of colour-IDs

      function shuffle(arr) {
        for (let i = arr.length-1; i>0; i--) {
          const j = Math.floor(Math.random()*(i+1));
          [arr[i],arr[j]] = [arr[j],arr[i]];
        }
        return arr;
      }
      let deck = shuffle([0,1,2,3]); // represents colours
      // Deal one, then reshuffle when deck is empty…
      

      • You’ll never see a bias or streaks longer than one (until you reshuffle).

    3. Weighted or adaptive RNG
      • You can tweak the pick-probabilities at runtime based on the player’s performance.
      – E.g. if the user’s on a losing streak, you give them more “easy” colours (lower‐contrast ones), or you reduce the pool size.
      • Implementation: keep a weight vector w=[w₁…wₙ], pick index i with probability wᵢ/∑wⱼ.

    4. Cryptographically secure RNG
      • If fairness is paramount (e.g. gambling), use a CSPRNG:
      – In browsers: window.crypto.getRandomValues(…).
      – In Node: crypto.randomInt(0, colours.length).

    5. Pattern-based (Markov chain, ML)
      • Some “prediction” demos actually try to learn your habits:
      – They track the last k colours you clicked and build a transition table.
      – Next-colour probabilities come from P(next|lastₖ).
      • Allows them to “beat” or “bounce off” your tendencies.

    Which of these sounds most like the game you’re curious about? Let me know if you need sample code or a deeper dive into any one of these approaches!

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