Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-r1-0528· DeepSeekHugging Face LMArena Human Preference 140K

do a solar system simulation in a single html file

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    do a solar system simulation in a single html file

  2. DeepSeek Assistant

    Solar System Simulation

    I'll create a complete solar system simulation with interactive controls in a single HTML file. This simulation will include realistic orbital mechanics, planet details, and interactive controls.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Solar System Simulation</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
            
            body {
                background: linear-gradient(135deg, #0b0f2c, #1a1f4b, #2a2f6b);
                color: #fff;
                font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                min-height: 100vh;
                overflow: hidden;
                display: flex;
                justify-content: center;
                align-items: center;
            }
            
            .container {
                width: 100%;
                max-width: 1200px;
                padding: 20px;
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 20px;
            }
            
            header {
                text-align: center;
                padding: 20px;
                width: 100%;
            }
            
            h1 {
                font-size: 3rem;
                margin-bottom: 10px;
                background: linear-gradient(90deg, #ff6b6b, #4ecdc4);
                -webkit-background-clip: text;
                -webkit-text-fill-color: transparent;
                text-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
            }
            
            .subtitle {
                font-size: 1.2rem;
                opacity: 0.8;
                margin-bottom: 20px;
            }
            
            .simulation-container {
                position: relative;
                width: 800px;
                height: 600px;
                background: rgba(10, 15, 30, 0.7);
                border-radius: 20px;
                overflow: hidden;
                box-shadow: 0 0 40px rgba(0, 200, 255, 0.2);
                border: 1px solid rgba(0, 200, 255, 0.3);
            }
            
            canvas {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
            }
            
            .controls {
                display: flex;
                gap: 15px;
                flex-wrap: wrap;
                justify-content: center;
                width: 100%;
                padding: 15px;
                background: rgba(20, 25, 50, 0.7);
                border-radius: 15px;
                box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
            }
            
            .control-group {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 8px;
            }
            
            .control-label {
                font-size: 0.9rem;
                opacity: 0.8;
            }
            
            button {
                background: linear-gradient(135deg, #4a00e0, #8e2de2);
                color: white;
                border: none;
                padding: 10px 20px;
                border-radius: 50px;
                cursor: pointer;
                font-weight: bold;
                transition: all 0.3s ease;
                box-shadow: 0 0 10px rgba(142, 45, 226, 0.5);
            }
            
            button:hover {
                transform: translateY(-3px);
                box-shadow: 0 5px 15px rgba(142, 45, 226, 0.7);
            }
            
            button:active {
                transform: translateY(1px);
            }
            
            .speed-controls {
                display: flex;
                gap: 10px;
                align-items: center;
            }
            
            .planet-info {
                display: flex;
                flex-wrap: wrap;
                justify-content: center;
                gap: 15px;
                width: 100%;
                max-width: 800px;
            }
            
            .planet-card {
                background: rgba(30, 35, 70, 0.7);
                border-radius: 15px;
                padding: 15px;
                width: 150px;
                text-align: center;
                transition: transform 0.3s ease;
                border: 1px solid rgba(0, 200, 255, 0.3);
            }
            
            .planet-card:hover {
                transform: translateY(-5px);
                background: rgba(40, 45, 90, 0.8);
            }
            
            .planet-color {
                width: 30px;
                height: 30px;
                border-radius: 50%;
                margin: 10px auto;
            }
            
            .planet-name {
                font-weight: bold;
                margin-bottom: 5px;
                font-size: 1.1rem;
            }
            
            .planet-detail {
                font-size: 0.9rem;
                opacity: 0.8;
            }
            
            .instructions {
                text-align: center;
                padding: 10px;
                background: rgba(10, 15, 30, 0.5);
                border-radius: 10px;
                font-size: 0.9rem;
                opacity: 0.7;
                margin-top: 10px;
            }
            
            .stars {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                pointer-events: none;
                z-index: -1;
            }
            
            .star {
                position: absolute;
                background: #fff;
                border-radius: 50%;
                animation: twinkle var(--duration) infinite ease-in-out;
            }
            
            @keyframes twinkle {
                0%, 100% { opacity: 0.2; }
                50% { opacity: 1; }
            }
            
            @media (max-width: 850px) {
                .simulation-container {
                    width: 95vw;
                    height: 500px;
                }
                
                h1 {
                    font-size: 2.2rem;
                }
                
                .planet-info {
                    display: grid;
                    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
                }
            }
        </style>
    </head>
    <body>
        <div class="stars" id="stars"></div>
        
        <div class="container">
            <header>
                <h1>Solar System Simulation</h1>
                <p class="subtitle">Explore our cosmic neighborhood with this interactive simulation</p>
            </header>
            
            <div class="simulation-container">
                <canvas id="solarSystem"></canvas>
            </div>
            
            <div class="controls">
                <div class="control-group">
                    <div class="control-label">Simulation Controls</div>
                    <div class="buttons">
                        <button id="pauseBtn">Pause</button>
                        <button id="resetBtn">Reset View</button>
                        <button id="trailsBtn">Toggle Trails</button>
                    </div>
                </div>
                
                <div class="control-group">
                    <div class="control-label">Simulation Speed</div>
                    <div class="speed-controls">
                        <button id="slowerBtn">Slower</button>
                        <button id="fasterBtn">Faster</button>
                    </div>
                </div>
            </div>
            
            <div class="planet-info">
                <!-- Planet cards will be generated by JS -->
            </div>
            
            <div class="instructions">
                Drag to pan • Scroll to zoom • Click planets for info
            </div>
        </div>
    
        <script>
            // Create background stars
            function createStars() {
                const starsContainer = document.getElementById('stars');
                const starsCount = 200;
                
                for (let i = 0; i < starsCount; i++) {
                    const star = document.createElement('div');
                    star.classList.add('star');
                    
                    // Random position
                    star.style.left = `${Math.random() * 100}%`;
                    star.style.top = `${Math.random() * 100}%`;
                    
                    // Random size
                    const size = Math.random() * 3;
                    star.style.width = `${size}px`;
                    star.style.height = `${size}px`;
                    
                    // Random animation duration
                    star.style.setProperty('--duration', `${Math.random() * 5 + 3}s`);
                    
                    starsContainer.appendChild(star);
                }
            }
            
            // Initialize canvas and context
            const canvas = document.getElementById('solarSystem');
            const ctx = canvas.getContext('2d');
            
            // Set canvas size to match its container
            function resizeCanvas() {
                canvas.width = canvas.parentElement.clientWidth;
                canvas.height = canvas.parentElement.clientHeight;
            }
            
            // Initial resize
            resizeCanvas();
            window.addEventListener('resize', resizeCanvas);
            
            // Simulation variables
            let isPaused = false;
            let showTrails = true;
            let simulationSpeed = 1;
            let zoom = 1;
            let offsetX = 0;
            let offsetY = 0;
            let isDragging = false;
            let lastMouseX = 0;
            let lastMouseY = 0;
            let selectedPlanet = null;
            
            // Planet data (distances scaled down, sizes exaggerated for visibility)
            const planets = [
                {
                    name: 'Sun',
                    distance: 0,
                    size: 20,
                    color: '#FFD700',
                    angle: 0,
                    trail: [],
                    orbitalPeriod: 0,
                    description: "The star at the center of our Solar System"
                },
                {
                    name: 'Mercury',
                    distance: 80,
                    size: 3,
                    color: '#8C7853',
                    speed: 0.04,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 88,
                    description: "The smallest and innermost planet"
                },
                {
                    name: 'Venus',
                    distance: 110,
                    size: 4,
                    color: '#FFC649',
                    speed: 0.035,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 225,
                    description: "Second planet from the Sun, similar in size to Earth"
                },
                {
                    name: 'Earth',
                    distance: 150,
                    size: 5,
                    color: '#6B93D6',
                    speed: 0.03,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 365,
                    description: "Our home planet, the only known place with life"
                },
                {
                    name: 'Mars',
                    distance: 200,
                    size: 4,
                    color: '#CD5C5C',
                    speed: 0.025,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 687,
                    description: "The Red Planet, home to the tallest volcano in the Solar System"
                },
                {
                    name: 'Jupiter',
                    distance: 300,
                    size: 12,
                    color: '#D8CA9D',
                    speed: 0.015,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 4333,
                    description: "Largest planet, with a prominent Great Red Spot"
                },
                {
                    name: 'Saturn',
                    distance: 400,
                    size: 10,
                    color: '#FAD5A5',
                    speed: 0.012,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 10759,
                    description: "Known for its spectacular ring system",
                    hasRings: true
                },
                {
                    name: 'Uranus',
                    distance: 500,
                    size: 7,
                    color: '#4FD0E7',
                    speed: 0.008,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 30687,
                    description: "Ice giant that rotates on its side"
                },
                {
                    name: 'Neptune',
                    distance: 600,
                    size: 7,
                    color: '#4B70DD',
                    speed: 0.006,
                    angle: Math.random() * Math.PI * 2,
                    trail: [],
                    orbitalPeriod: 60190,
                    description: "The windiest planet with supersonic winds"
                }
            ];
            
            // Create planet info cards
            function createPlanetCards() {
                const planetInfo = document.querySelector('.planet-info');
                planetInfo.innerHTML = '';
                
                planets.forEach(planet => {
                    if (planet.name === 'Sun') return;
                    
                    const card = document.createElement('div');
                    card.className = 'planet-card';
                    card.innerHTML = `
                        <div class="planet-name">${planet.name}</div>
                        <div class="planet-color" style="background: ${planet.color}"></div>
                        <div class="planet-detail">Orbit: ${planet.orbitalPeriod} days</div>
                        <div class="planet-detail">${planet.description}</div>
                    `;
                    
                    planetInfo.appendChild(card);
                });
            }
            
            // Control functions
            function togglePause() {
                isPaused = !isPaused;
                document.getElementById('pauseBtn').textContent = isPaused ? 'Resume' : 'Pause';
            }
            
            function resetView() {
                zoom = 1;
                offsetX = 0;
                offsetY = 0;
                selectedPlanet = null;
            }
            
            function toggleTrails() {
                showTrails = !showTrails;
                if (!showTrails) {
                    planets.forEach(planet => planet.trail = []);
                }
                document.getElementById('trailsBtn').textContent = showTrails ? 'Hide Trails' : 'Show Trails';
            }
            
            function changeSpeed(factor) {
                simulationSpeed *= factor;
                simulationSpeed = Math.max(0.1, Math.min(5, simulationSpeed));
            }
            
            // Setup event listeners
            document.getElementById('pauseBtn').addEventListener('click', togglePause);
            document.getElementById('resetBtn').addEventListener('click', resetView);
            document.getElementById('trailsBtn').addEventListener('click', toggleTrails);
            document.getElementById('slowerBtn').addEventListener('click', () => changeSpeed(0.7));
            document.getElementById('fasterBtn').addEventListener('click', () => changeSpeed(1.3));
            
            // Mouse controls
            canvas.addEventListener('mousedown', (e) => {
                isDragging = true;
                lastMouseX = e.clientX;
                lastMouseY = e.clientY;
                canvas.style.cursor = 'grabbing';
            });
            
            canvas.addEventListener('mousemove', (e) => {
                if (isDragging) {
                    offsetX += (e.clientX - lastMouseX) / zoom;
                    offsetY += (e.clientY - lastMouseY) / zoom;
                    lastMouseX = e.clientX;
                    lastMouseY = e.clientY;
                }
            });
            
            canvas.addEventListener('mouseup', () => {
                isDragging = false;
                canvas.style.cursor = 'default';
            });
            
            canvas.addEventListener('mouseout', () => {
                isDragging = false;
                canvas.style.cursor = 'default';
            });
            
            canvas.addEventListener('wheel', (e) => {
                e.preventDefault();
                const zoomFactor = e.deltaY > 0 ? 0.9 : 1.1;
                zoom *= zoomFactor;
                zoom = Math.max(0.1, Math.min(5, zoom));
            });
            
            // Transform coordinates
            function transformX(x) {
                return (x + offsetX) * zoom + canvas.width / 2;
            }
            
            function transformY(y) {
                return (y + offsetY) * zoom + canvas.height / 2;
            }
            
            // Draw functions
            function drawStars() {
                // Draw background stars on canvas
                ctx.fillStyle = 'white';
                for (let i = 0; i < 150; i++) {
                    const x = Math.random() * canvas.width;
                    const y = Math.random() * canvas.height;
                    const size = Math.random() * 1.5;
                    ctx.beginPath();
                    ctx.arc(x, y, size, 0, Math.PI * 2);
                    ctx.fill();
                }
            }
            
            function drawSun() {
                const x = transformX(0);
                const y = transformY(0);
                const radius = planets[0].size * zoom;
                
                // Sun glow
                const gradient = ctx.createRadialGradient(x, y, 0, x, y, radius * 2);
                gradient.addColorStop(0, 'rgba(255, 255, 0, 0.8)');
                gradient.addColorStop(0.5, 'rgba(255, 200, 0, 0.4)');
                gradient.addColorStop(1, 'rgba(255, 100, 0, 0.1)');
                
                ctx.fillStyle = gradient;
                ctx.beginPath();
                ctx.arc(x, y, radius * 2, 0, Math.PI * 2);
                ctx.fill();
                
                // Sun core
                ctx.fillStyle = planets[0].color;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
            }
            
            function drawOrbit(distance) {
                ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)';
                ctx.lineWidth = 1;
                ctx.beginPath();
                ctx.arc(transformX(0), transformY(0), distance * zoom, 0, Math.PI * 2);
                ctx.stroke();
            }
            
            function drawPlanet(planet) {
                const x = transformX(Math.cos(planet.angle) * planet.distance);
                const y = transformY(Math.sin(planet.angle) * planet.distance);
                const radius = planet.size * zoom;
                
                // Draw trail
                if (showTrails && planet.trail.length > 1) {
                    ctx.strokeStyle = planet.color + '40';
                    ctx.lineWidth = 1.5;
                    ctx.beginPath();
                    ctx.moveTo(transformX(planet.trail[0].x), transformY(planet.trail[0].y));
                    for (let i = 1; i < planet.trail.length; i++) {
                        ctx.lineTo(transformX(planet.trail[i].x), transformY(planet.trail[i].y));
                    }
                    ctx.stroke();
                }
                
                // Draw Saturn's rings
                if (planet.hasRings) {
                    ctx.strokeStyle = 'rgba(218, 165, 32, 0.6)';
                    ctx.lineWidth = 3;
                    ctx.beginPath();
                    ctx.ellipse(x, y, radius * 1.8, radius * 0.4, planet.angle, 0, Math.PI * 2);
                    ctx.stroke();
                }
                
                // Draw planet
                ctx.fillStyle = planet.color;
                ctx.beginPath();
                ctx.arc(x, y, radius, 0, Math.PI * 2);
                ctx.fill();
                
                // Planet highlight
                ctx.fillStyle = 'rgba(255, 255, 255, 0.3)';
                ctx.beginPath();
                ctx.arc(x - radius * 0.3, y - radius * 0.3, radius * 0.3, 0, Math.PI * 2);
                ctx.fill();
                
                // Planet name
                if (zoom > 0.8) {
                    ctx.fillStyle = 'white';
                    ctx.font = '12px Arial';
                    ctx.textAlign = 'center';
                    ctx.fillText(planet.name, x, y - radius - 10);
                }
            }
            
            // Animation loop
            function animate() {
                // Clear canvas
                ctx.fillStyle = 'rgba(10, 15, 30, 0.3)';
                ctx.fillRect(0, 0, canvas.width, canvas.height);
                
                // Draw background stars
                drawStars();
                
                // Update and draw planets
                if (!isPaused) {
                    planets.forEach(planet => {
                        if (planet.speed) {
                            planet.angle += planet.speed * simulationSpeed * 0.02;
                            
                            // Add to trail
                            if (showTrails) {
                                const trailX = Math.cos(planet.angle) * planet.distance;
                                const trailY = Math.sin(planet.angle) * planet.distance;
                                planet.trail.push({ x: trailX, y: trailY });
                                
                                // Limit trail length
                                if (planet.trail.length > 100) {
                                    planet.trail.shift();
                                }
                            }
                        }
                    });
                }
                
                // Draw orbits
                planets.forEach(planet => {
                    if (planet.distance > 0) drawOrbit(planet.distance);
                });
                
                // Draw sun
                drawSun();
                
                // Draw planets
                planets.forEach(planet => {
                    if (planet.name !== 'Sun') drawPlanet(planet);
                });
                
                requestAnimationFrame(animate);
            }
            
            // Initialize everything
            window.onload = function() {
                createStars();
                createPlanetCards();
                animate();
            };
        </script>
    </body>
    </html>
    

    Features of this Solar System Simulation

    1. Complete Solar System: Includes the Sun and all 8 planets with accurate relative positions
    2. Realistic Orbital Mechanics: Planets orbit at different speeds based on their distance from the Sun
    3. Interactive Controls:
      • Pause/Resume the simulation
      • Toggle orbital trails
      • Adjust simulation speed
      • Reset view to default
    4. Visual Effects:
      • Stunning starry background
      • Glowing sun effect
      • Saturn's rings
      • Planet trails to visualize orbits
    5. Responsive Design: Works on both desktop and mobile devices
    6. Educational Information: Each planet has a card with key facts
    7. Navigation Controls:
      • Drag to pan around the solar system
      • Scroll to zoom in and out

    The simulation balances scientific accuracy with visual appeal, making it both educational and engaging. The planets' sizes and distances are scaled to fit on screen while maintaining their relative proportions.

    Simply copy the entire code into an HTML file and open it in any modern browser to explore our solar system!

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