BrowserQuest-PHP is a multiplayer online game based on Mozilla's BrowserQuest, with the backend rewritten in PHP using the Workerman framework. This repository provides a Dockerized setup for easy deployment and management, now with dynamic NPC dialogues powered by Ollama.
- Fully Dockerized for simple deployment
- Configurable WebSocket host and port
- Persistent configuration for development and production
- Multilingual support with enhanced language selector
- Multilingual instructions (English and Spanish)
- NEW: AI-powered NPC dialogues using Ollama
- NEW: Dynamic, contextual NPC responses based on player equipment and status
- NEW: Multilingual AI responses that match the game's selected language
- Docker
- Docker Compose
- Ollama (for AI-powered NPC dialogues)
git clone https://github.com/your-repo/BrowserQuest-PHP-LLM.git
cd BrowserQuest-PHP-LLMEdit the docker-compose.yml file to set the HOST_ADDRESS environment variable. This variable determines the WebSocket server's address that the client will connect to.
-
Localhost (same machine):
environment: - HOST_ADDRESS=localhost
-
Local network (accessible from other devices):
environment: - HOST_ADDRESS=192.168.1.100
-
Public domain:
environment: - HOST_ADDRESS=yourdomain.com
Run the following command to build the Docker image:
docker-compose buildStart the server in detached mode:
docker-compose up -dOpen your browser and navigate to:
- Frontend: http://localhost:8787
- WebSocket:
ws://localhost:8000
Replace localhost with the IP or domain you configured in HOST_ADDRESS.
The game now features a dramatically improved language selection system:
- Large, prominent language buttons on the initial screen for easy language selection
- Persistent language settings saved to the browser's local storage
- On-the-fly translation without page reload
- Automatic language detection based on browser settings
- Visual indicators showing the currently active language
- Small language toggle available at all times in the top corner
Currently supported languages:
- English
- Spanish
This version of BrowserQuest-PHP includes integration with Ollama, allowing NPCs to generate dynamic, contextual responses using AI language models.
- NPCs now generate unique responses based on their character type and player context
- Responses adapt to player's equipment, health status, and other game factors
- The system supports multiple languages (currently English and Spanish)
- Responses are more varied, natural, and immersive than static dialogue
-
Install Ollama
Follow the installation instructions at ollama.ai for your operating system.
-
Pull the Recommended Model
Pull the following model or another model of your choice:
ollama pull hf.co/soob3123/amoral-gemma3-1B-v2-gguf:Q8_0
-
Configure Ollama in BrowserQuest
Edit the Ollama configuration file at
Server/Config/ollama.phpto change settings:// Change the Ollama API URL if needed (default works with Docker) 'api_base' => 'http://host.docker.internal:11434', // Change the model name if you prefer to use a different model 'model' => 'hf.co/soob3123/amoral-gemma3-1B-v2-gguf:Q8_0',
When you talk to NPCs in the game, the system will use Ollama to generate dynamic responses. Here are some tips:
- For varied responses: When interacting with an NPC, clicking repeatedly will generate different responses (sometimes it may take 2-3 clicks to see changes - we're working on improving this)
- Contextual dialogues: NPCs will recognize your character's equipment, health status, and respond accordingly
- Language matching: Responses will be in the same language you've selected for the game interface
If Ollama is not available or encounters an error, the system will automatically fall back to the original static dialogues. This ensures the game remains playable even if the AI service is down.
You can customize how NPCs respond by editing the context templates in Server/Config/ollama.php. Each NPC type has different personality traits and knowledge that influence their responses.
To monitor the server logs:
docker-compose logs -fTo stop and remove the container:
docker-compose downIf you see this error after creating a character, it means the client cannot connect to the WebSocket server. Ensure the following:
- The
HOST_ADDRESSindocker-compose.ymlis correctly set to the IP or domain accessible from the client. - The WebSocket port (default: 8000) is open and accessible.
- Check the logs for any errors:
docker-compose logs
You can change the external ports by modifying the ports section in docker-compose.yml:
ports:
- "9000:8000" # WebSocket port
- "8080:8787" # HTTP portThe Web/config directory is mounted as a volume in the container. Any changes made to the configuration files will persist across container restarts.
- Docker
- Docker Compose
- Ollama (para los diálogos de NPCs generados por IA)
-
Clonar el Repositorio
git clone https://github.com/your-repo/BrowserQuest-PHP.git cd BrowserQuest-PHP -
Configurar el Entorno Docker
Edita el archivo
docker-compose.ymly establece la variableHOST_ADDRESScon la dirección IP o dominio del servidor.-
Localhost (misma máquina):
environment: - HOST_ADDRESS=localhost
-
Red local (accesible desde otros dispositivos):
environment: - HOST_ADDRESS=192.168.1.100
-
Dominio público:
environment: - HOST_ADDRESS=tu-dominio.com
-
-
Construir la Imagen Docker
docker-compose build
-
Iniciar el Servidor
docker-compose up -d
-
Acceder al Juego
Abre tu navegador y visita:
- Frontend: http://localhost:8787
- WebSocket:
ws://localhost:8000
Reemplaza
localhostcon la IP o dominio configurado enHOST_ADDRESS.
Esta versión de BrowserQuest-PHP incluye integración con Ollama, permitiendo que los NPCs generen respuestas dinámicas y contextuales utilizando modelos de lenguaje de IA.
- Los NPCs ahora generan respuestas únicas basadas en su tipo de personaje y el contexto del jugador
- Las respuestas se adaptan al equipamiento del jugador, estado de salud y otros factores del juego
- El sistema soporta múltiples idiomas (actualmente inglés y español)
- Las respuestas son más variadas, naturales e inmersivas que los diálogos estáticos
-
Instalar Ollama
Sigue las instrucciones de instalación en ollama.ai para tu sistema operativo.
-
Descargar el Modelo Recomendado
Descarga el siguiente modelo o cualquier otro modelo de tu elección:
ollama pull hf.co/soob3123/amoral-gemma3-1B-v2-gguf:Q8_0
-
Configurar Ollama en BrowserQuest
Edita el archivo de configuración de Ollama en
Server/Config/ollama.phppara cambiar la configuración:// Cambia la URL de la API de Ollama si es necesario (el valor predeterminado funciona con Docker) 'api_base' => 'http://host.docker.internal:11434', // Cambia el nombre del modelo si prefieres usar un modelo diferente 'model' => 'hf.co/soob3123/amoral-gemma3-1B-v2-gguf:Q8_0',
Cuando hablas con NPCs en el juego, el sistema utilizará Ollama para generar respuestas dinámicas. Aquí algunos consejos:
- Para respuestas variadas: Al interactuar con un NPC, hacer clic repetidamente generará respuestas diferentes (a veces puede tomar 2-3 clics para ver cambios - estamos trabajando para mejorar esto)
- Diálogos contextuales: Los NPCs reconocerán el equipamiento de tu personaje, estado de salud y responderán en consecuencia
- Coincidencia de idioma: Las respuestas estarán en el mismo idioma que hayas seleccionado para la interfaz del juego
Si Ollama no está disponible o encuentra un error, el sistema automáticamente utilizará los diálogos estáticos originales. Esto asegura que el juego permanezca jugable incluso si el servicio de IA no está funcionando.
Puedes personalizar cómo responden los NPCs editando las plantillas de contexto en Server/Config/ollama.php. Cada tipo de NPC tiene diferentes rasgos de personalidad y conocimientos que influyen en sus respuestas.
El juego ahora cuenta con un sistema de selección de idiomas considerablemente mejorado:
- Botones de idioma grandes y destacados en la pantalla inicial para facilitar la selección
- Configuración de idioma persistente guardada en el almacenamiento local del navegador
- Traducción instantánea sin necesidad de recargar la página
- Detección automática del idioma basada en la configuración del navegador
- Indicadores visuales que muestran el idioma actualmente activo
- Selector de idioma pequeño disponible en todo momento en la esquina superior
Idiomas actualmente soportados:
- Inglés
- Español
Si ves este error después de crear un personaje, verifica lo siguiente:
- La variable
HOST_ADDRESSendocker-compose.ymlestá configurada correctamente. - El puerto WebSocket (por defecto: 8000) está abierto y accesible.
- Revisa los logs para identificar errores:
docker-compose logs
Para detener y eliminar el contenedor:
docker-compose down
