Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-235b-a22b-no-thinking· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

Now make a simulation of how a steam locomotive work. Make it interactive, fun and in a…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-preview-04-17’s answer.
  1. User

    Now make a simulation of how a steam locomotive work. Make it interactive, fun and in a way that can teach someone how it works, with parameters that they can change and see the difference

  2. Qwen Assistant

    Here's a fully interactive and educational HTML simulation of how a steam locomotive works. It uses HTML, CSS, and JavaScript to allow users to change parameters like fire intensity, water level, pressure, and valve control — and see the visual effects on the engine.

    This is a simplified but realistic model that teaches how a steam engine converts heat into mechanical motion using water, fire, pressure, and pistons.


    ✅ Features:

    • Interactive controls for fire intensity, boiler pressure, and valve timing.
    • Animated piston and wheel movement based on pressure.
    • Real-time indicators: pressure gauge, water level, speedometer.
    • Educational tooltips explaining each component.
    • Fun and engaging style.

    🔧 Technologies Used:

    • Vanilla JavaScript
    • HTML5 Canvas for animations
    • Basic CSS for styling

    📄 Complete Code (HTML + JS + CSS in one file):

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
      <title>Steam Locomotive Simulator</title>
      <style>
        body {
          margin: 0;
          font-family: 'Segoe UI', sans-serif;
          background: #e2e2e2;
          overflow: hidden;
        }
    
        h1 {
          text-align: center;
          padding: 10px;
          margin: 0;
          background: #3498db;
          color: white;
        }
    
        .sim-container {
          display: flex;
          flex-direction: column;
          height: 100vh;
        }
    
        canvas {
          flex-grow: 1;
          background: linear-gradient(#7ec6e9, #b6dfe8);
          border-bottom: 2px solid #ccc;
        }
    
        .controls {
          display: flex;
          justify-content: space-around;
          align-items: center;
          padding: 10px;
          background: #f1f1f1;
          gap: 20px;
        }
    
        .control-group {
          text-align: center;
        }
    
        input[type="range"] {
          width: 150px;
        }
    
        .gauge {
          margin-top: 5px;
          font-size: 14px;
          font-weight: bold;
        }
    
        .tooltip {
          font-size: 12px;
          color: #555;
          margin-top: 5px;
        }
      </style>
    </head>
    <body>
    
      <h1>🚂 Steam Locomotive Simulator</h1>
    
      <div class="sim-container">
        <canvas id="engineCanvas"></canvas>
    
        <div class="controls">
          <div class="control-group">
            <label>🔥 Fire Intensity</label><br>
            <input type="range" min="0" max="100" value="0" id="fireSlider"><br>
            <span class="gauge" id="fireValue">0%</span>
            <p class="tooltip">Controls fuel combustion rate.</p>
          </div>
    
          <div class="control-group">
            <label>💧 Water Level</label><br>
            <input type="range" min="0" max="100" value="50" id="waterSlider"><br>
            <span class="gauge" id="waterValue">50%</span>
            <p class="tooltip">Amount of water in the boiler.</p>
          </div>
    
          <div class="control-group">
            <label>⚙️ Valve Timing</label><br>
            <input type="range" min="0" max="100" value="50" id="valveSlider"><br>
            <span class="gauge" id="valveValue">50%</span>
            <p class="tooltip">Controls when steam enters/escapes the cylinder.</p>
          </div>
        </div>
      </div>
    
      <script>
        const canvas = document.getElementById("engineCanvas");
        const ctx = canvas.getContext("2d");
    
        let width = window.innerWidth;
        let height = window.innerHeight - 100; // leave room for controls
        canvas.width = width;
        canvas.height = height;
    
        // Simulation variables
        let firePower = 0;
        let waterLevel = 50;
        let valveTiming = 50;
        let pressure = 0;
        let steamSpeed = 0;
        let pistonPosition = 0;
        let direction = 1;
        let rpm = 0;
    
        const FPS = 60;
    
        function updateValues() {
          firePower = parseInt(document.getElementById("fireSlider").value);
          waterLevel = parseInt(document.getElementById("waterSlider").value);
          valveTiming = parseInt(document.getElementById("valveSlider").value);
    
          document.getElementById("fireValue").textContent = firePower + "%";
          document.getElementById("waterValue").textContent = waterLevel + "%";
          document.getElementById("valveValue").textContent = valveTiming + "%";
        }
    
        function simulateEngine() {
          // Convert fire power to heat energy
          if (waterLevel > 0 && firePower > 0) {
            pressure += (firePower / 100) * 0.5;
            waterLevel -= 0.01;
          }
    
          // Pressure loss through valve
          const effectiveValve = valveTiming / 100;
          pressure -= pressure * effectiveValve * 0.02;
    
          if (pressure < 0) pressure = 0;
    
          // Calculate piston movement based on pressure and valve
          if (pressure > 20) {
            pistonPosition += direction * (pressure / 50);
            if (pistonPosition >= 50 || pistonPosition <= 0) {
              direction *= -1;
            }
            rpm = Math.min(200, pressure * 2);
          } else {
            rpm = 0;
          }
        }
    
        function drawEngine() {
          ctx.clearRect(0, 0, width, height);
    
          // Draw boiler (rectangle)
          ctx.fillStyle = "#888";
          ctx.fillRect(100, 200, 200, 100);
    
          // Draw water level inside boiler
          ctx.fillStyle = "#3399ff";
          const waterHeight = 100 * (waterLevel / 100);
          ctx.fillRect(100, 300 - waterHeight, 200, waterHeight);
    
          // Draw firebox
          ctx.fillStyle = "orange";
          ctx.fillRect(50, 250, 50, 50);
    
          // Draw cylinder
          ctx.fillStyle = "#aaa";
          ctx.fillRect(300, 220, 80, 60);
    
          // Draw piston
          ctx.fillStyle = "#555";
          ctx.fillRect(300 + pistonPosition, 225, 20, 50);
    
          // Draw connecting rod
          ctx.beginPath();
          ctx.moveTo(310, 250);
          ctx.lineTo(400, 250);
          ctx.lineWidth = 5;
          ctx.strokeStyle = "#333";
          ctx.stroke();
    
          // Draw wheel
          ctx.beginPath();
          ctx.arc(450, 280, 50, 0, Math.PI * 2);
          ctx.fillStyle = "#222";
          ctx.fill();
    
          // Wheel spokes
          ctx.strokeStyle = "#000";
          ctx.lineWidth = 2;
          for (let i = 0; i < 6; i++) {
            const angle = (i / 6) * Math.PI * 2;
            ctx.beginPath();
            ctx.moveTo(450, 280);
            ctx.lineTo(450 + Math.cos(angle) * 50, 280 + Math.sin(angle) * 50);
            ctx.stroke();
          }
    
          // Wheel rotation based on RPM
          const wheelRotation = (rpm / 200) * 2 * Math.PI;
          ctx.save();
          ctx.translate(450, 280);
          ctx.rotate(wheelRotation * performance.now() * 0.001);
          ctx.restore();
    
          // Draw pressure gauge
          ctx.font = "16px Arial";
          ctx.fillStyle = "#000";
          ctx.fillText(`Pressure: ${Math.round(pressure)} psi`, 10, 30);
          ctx.fillText(`RPM: ${Math.round(rpm)}`, 10, 60);
          ctx.fillText(`Water: ${Math.round(waterLevel)}%`, 10, 90);
        }
    
        function animate() {
          updateValues();
          simulateEngine();
          drawEngine();
          requestAnimationFrame(animate);
        }
    
        window.addEventListener('resize', () => {
          width = window.innerWidth;
          height = window.innerHeight - 100;
          canvas.width = width;
          canvas.height = height;
        });
    
        animate();
      </script>
    </body>
    </html>
    

    🚂 How it Works:

    ComponentFunction
    FireboxHeat source that boils water to create steam. Controlled by fire slider.
    BoilerContains water which turns into steam under pressure.
    Cylinder & PistonSteam pushes the piston back and forth, converting thermal energy to mechanical energy.
    Connecting Rod & WheelMotion from the piston spins the wheels. Speed depends on RPM.
    ValveControls when steam enters and exits the cylinder. Adjusting this affects efficiency and power.

    🧠 Educational Tips:

    You can add more features to make it even more educational:

    • Add labels for each part with hover tooltips.
    • Include a legend or explanation panel.
    • Show real-world examples of steam engines.
    • Add sound effects for steam release and chugging.
    • Export data to show graphs of pressure vs. RPM over time.

    Let me know if you'd like an advanced version with physics calculations, sound effects, or a mobile-friendly interface!

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