Skip to main content

Get Started in Minutes

This guide will walk you through your first Pica y Fija game, from creating a room to making your winning guess.
Pica y Fija requires exactly 2 players. You’ll need a friend to play with, or you can join a public room to be matched with another player.

Playing the Game

1

Access the Game

Navigate to the game in your browser. You’ll see the lobby screen with three options:
  • 🎮 Crear Sala (Create Room)
  • 🔎 Buscar Sala (Find Public Room)
  • 📩 Unirse por Código (Join by Code)
The game uses WebSocket connections for real-time communication, so make sure your network allows WebSocket traffic.
2

Create or Join a Room

Choose one of the following methods:

Option A: Create a Private Room

  1. Click “Crear Sala”
  2. Configure your game settings:
    • Tiempo por turno: Set turn duration in seconds (default: 60)
    • Sala pública: Check to make room discoverable
    • Requiere aprobación: Check to manually approve joiners
  3. Click “Confirmar”
  4. Share the room code with your friend
// Server generates a unique 6-character room code
function generateRoomCode() {
  return Math.random().toString(36).substring(2, 8).toUpperCase();
}
Room codes are randomly generated and case-insensitive. Make sure to share the exact code with your opponent.

Option B: Join a Public Room

  1. Click “Buscar Sala”
  2. The game will automatically match you with an available public room
  3. If no rooms are available, you’ll see: “No hay salas públicas disponibles”

Option C: Join by Code

  1. Click “Unirse por Código”
  2. Enter the room code (6 characters)
  3. Click “Unirse”
The game validates that:
  • The room exists
  • The room has space (maximum 2 players)
socket.on('unirseSala', (codigo) => {
  const room = rooms[codigo];
  if (!room) {
    socket.emit('error', 'Sala no encontrada');
    return;
  }
  if (room.players.length >= 2) {
    socket.emit('error', 'La sala ya está llena');
    return;
  }
  joinRoom(socket, codigo);
});
3

Set Your Secret Number

Once both players are in the room, you’ll see the game interface with a secret number input.Choose your 4-digit secret number:
  • Must be exactly 4 digits
  • All digits must be different (e.g., 1234 ✓, 1123 ✗)
  • Enter it in the “Número secreto” field
  • Click “Estoy Listo” (I’m Ready)
Once you submit your secret number, you cannot change it! Choose carefully.
Example valid numbers: 1234, 5678, 9012, 4567
Invalid numbers: 1123 (repeated 1), 5555 (all same), 123 (only 3 digits)
The server validates your input:
if (!/^\d{4}$/.test(secret) || new Set(secret).size !== 4) {
  socket.emit('error', 'El número debe tener 4 cifras diferentes');
  return;
}
After both players submit their secrets, the game begins automatically and you’ll hear the game start sound.
4

Make Your Guesses

The game alternates turns between players. When it’s your turn:
  1. You’ll see:
    • 🟢 “¡Es tu turno!” message
    • The guess input field becomes enabled
    • A countdown timer starts (⏳ Tiempo restante: XXs)
  2. Enter your guess in the “Tu intento” field (4 unique digits)
  3. Click “Adivinar” before time runs out
  4. Review the feedback in the results table:
    • Jugador (Player): “yo” (you) or “oponente” (opponent)
    • Turno (Turn): Turn number
    • Intento (Attempt): The guessed number
    • Picas: Correct digits in wrong positions
    • Fijas: Correct digits in correct positions

Understanding the Feedback

Let’s say the secret number is 1234:
Your GuessPicasFijasExplanation
123404Perfect! You win!
1243221 and 2 are fixed, 3 and 4 are in wrong positions
567800No correct digits
432140All correct digits, all wrong positions
156701Only 1 is correct and in the right position
Use the filter dropdown to view:
  • Todos los turnos: All attempts from both players
  • Solo mis turnos: Only your attempts
  • Solo del oponente: Only opponent’s attempts

Turn Timer

Each turn has a time limit set by the room creator. If you don’t guess in time:
  • ⏰ “Se acabó el tiempo del turno. Pasando turno…”
  • Your turn ends automatically
  • The turn passes to your opponent
if (timeLeft <= 0) {
  socket.emit('pasarTurnoPorTiempo');
}
5

Win the Game

Continue making guesses and analyzing feedback until:You Win 🎉
  • You get 4 Fijas (all digits correct in correct positions)
  • The overlay shows ”🎉 ¡Ganaste!”
  • Victory sound plays
  • The game ends
You Lose 💀
  • Your opponent gets 4 Fijas first
  • The overlay shows ”💀 Perdiste”
  • Defeat sound plays
  • The game ends
The server marks the game as over:
if (result.fijas === 4) {
  room.gameOver = true;
}
After a game ends, you’ll need to create or join a new room to play again.

Quick Tips for Success

For your first guess, use digits that are far apart (e.g., 1357 or 2468) to maximize information gained. This helps you quickly identify which digits are in the secret number.
The results table shows all your previous guesses and their feedback. Use this history to deduce the secret number logically. Pay attention to patterns in Picas and Fijas.
Don’t let the clock run out! If you’re unsure, make an educated guess rather than losing your turn. You can always adjust your strategy on the next turn.
Filter the results table to focus on your own attempts when planning your next guess. This reduces visual clutter and helps you think clearly.

Example Game Flow

Here’s what a typical game looks like:
// Player 1 creates room
socket.emit('crearSala', { 
  tiempoTurno: 60, 
  publica: false, 
  requiereAprobacion: false 
});
// → Receives room code: "A3X7K9"

// Player 2 joins
socket.emit('unirseSala', 'A3X7K9');
// → Both players connected

// Both players set secrets
socket.emit('secret', '1234'); // Player 1
socket.emit('secret', '5678'); // Player 2
// → Game starts!

// Turn 1: Player 1 guesses
socket.emit('guess', '5432');
// → Result: { picas: 1, fijas: 1 }

// Turn 2: Player 2 guesses  
socket.emit('guess', '1987');
// → Result: { picas: 2, fijas: 0 }

// ... game continues until someone gets 4 fijas

Troubleshooting

The room code you entered doesn’t exist. Double-check the code with your friend or create a new room.
The room already has 2 players. Pica y Fija only supports 2 players per room. Create or join a different room.
Your secret number or guess has repeated digits or isn’t exactly 4 digits. Make sure all 4 digits are unique.
You tried to guess when it’s not your turn. Wait for the 🟢 “¡Es tu turno!” message before making a guess.
If your opponent disconnects, you’ll see “Tu oponente se ha desconectado” and the game will end. You’ll need to start a new game.

Next Steps

Game Rules

Learn detailed game rules and scoring

Architecture

Understand how the game is built
Now you’re ready to play! Create a room and challenge your friends to a battle of logic and deduction. May the best code-breaker win!

Build docs developers (and LLMs) love