Skip to main content

Game Objective

Pica y Fija is a two-player number guessing game where each player:
  1. Selects a secret 4-digit number with all different digits
  2. Takes turns trying to guess their opponent’s secret number
  3. Receives feedback in the form of “Picas” and “Fijas” after each guess
  4. Wins by being the first to guess their opponent’s number exactly (4 Fijas)

Getting Started

1

Join or Create a Room

You have three options to start playing:
  • Create a Room: Configure your game settings including turn time limit, public/private visibility
  • Search for Public Room: Automatically join an available public room
  • Join by Code: Enter a specific room code to join a friend’s game
Once two players are in a room, you’ll see a confirmation message:
// From index.html:232-237
socket.on('salaLista', data => {
  miJugadorId = data.jugador === 1 ? 0 : 1;
  tiempoTurnoConfigurado = data.tiempoTurno || 60;
  log.innerText += `✅ Te uniste como Jugador ${data.jugador} a la sala ${data.sala}\n`;
});
2

Choose Your Secret Number

Each player must enter a 4-digit secret number following these rules:
Valid Number Requirements:
  • Must be exactly 4 digits
  • All digits must be different (no repeating digits)
  • Can include 0-9
Valid Examples:
  • 1234
  • 5890
  • 0123
Invalid Examples:
  • 1123 ✗ (digit 1 repeats)
  • 5555 ✗ (all digits same)
  • 123 ✗ (only 3 digits)
  • 12345 ✗ (5 digits)
The server validates your secret number:
// From server.js:75-78
if (!/^\d{4}$/.test(secret) || new Set(secret).size !== 4) {
  socket.emit('error', 'El número debe tener 4 cifras diferentes');
  return;
}
Once both players submit valid secret numbers, the game begins automatically.
3

Wait for Your Turn

The game uses a turn-based system:
  • Player 1 goes first
  • Turns alternate between players
  • Each turn has a time limit (configurable, default 60 seconds)
  • If time runs out, your turn is automatically skipped
// From index.html:253-268
socket.on('turn', data => {
  if (data.yourTurn) {
    guessInput.disabled = false;
    guessBtn.disabled = false;
    log.innerText += '🟢 ¡Es tu turno!\n';
    sndTurno.play();
  } else {
    guessInput.disabled = true;
    guessBtn.disabled = true;
    log.innerText += '🔴 Esperando turno del oponente...\n';
  }
});
4

Make Your Guess

When it’s your turn:
  1. Enter a 4-digit number (same validation rules as secret numbers)
  2. Click “Adivinar” (Guess) to submit
  3. Receive instant feedback as Picas and Fijas
  4. Review the results table to track your progress
Your guess must also follow the same rules:
// From server.js:104-107
if (!/^\d{4}$/.test(guess) || new Set(guess).size !== 4) {
  socket.emit('error', 'El intento debe tener 4 cifras distintas');
  return;
}
5

Analyze Feedback and Strategy

After each guess, you’ll see:
  • Jugador: Who made the guess (you or opponent)
  • Turno: Turn number for that player
  • Intento: The guessed number
  • Picas: Right digits in wrong positions
  • Fijas: Right digits in right positions
Use the filter dropdown to view:
  • All turns (both players)
  • Only your turns
  • Only opponent’s turns
Keep track of your previous guesses and their Picas/Fijas to narrow down the possibilities. For example, if your guess 1234 returns 2 Picas and 0 Fijas, you know two of those digits are in the secret number but in different positions.
6

Win the Game

Continue making guesses until:
  • You win: You guess the exact number (4 Fijas) 🎉
  • Opponent wins: They guess your secret number first 💀
The game ends immediately when someone achieves 4 Fijas:
// From server.js:131-136
if (result.fijas === 4) {
  room.gameOver = true;
} else {
  room.turn = opponentId;
  broadcastTurn(room);
}

Turn Timer

Each turn has a countdown timer that:
  • Starts when your turn begins
  • Counts down from the configured time limit (default 60 seconds)
  • Displays remaining time as ⏳ Tiempo restante: Xs
  • Automatically passes your turn if it reaches 0
// From index.html:314-328
function startTimer() {
  timeLeft = tiempoTurnoConfigurado;
  updateTimer();
  countdown = setInterval(() => {
    timeLeft--;
    updateTimer();
    if (timeLeft <= 0) {
      stopTimer();
      guessInput.disabled = true;
      guessBtn.disabled = true;
      log.innerText += '⏰ Se acabó el tiempo del turno. Pasando turno...\n';
      socket.emit('pasarTurnoPorTiempo');
    }
  }, 1000);
}

Game Flow Summary

Tips for New Players

Start with a strategic first guess like 1234 or 5678 to gather maximum information about which digits are in the secret number.
Track your guesses systematically. The game provides a complete history table - use it to eliminate possibilities and identify patterns.
Remember that you cannot make a guess when:
  • It’s not your turn
  • The game has ended
  • Your secret number hasn’t been submitted yet
  • The number doesn’t meet validation requirements

Build docs developers (and LLMs) love