Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219-thinking-32k· AnthropicHugging Face LMArena Human Preference 140K

Generate a fully working minecraft clone in an html file

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4.1-2025-04-14’s answer.
  1. User

    Generate a fully working minecraft clone in an html file

  2. Claude Assistant
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>Browser Minecraft Clone</title>
        <style>
            body { margin: 0; overflow: hidden; }
            canvas { display: block; }
            #info {
                position: absolute;
                top: 10px;
                width: 100%;
                text-align: center;
                color: white;
                font-family: Arial, sans-serif;
            }
        </style>
    </head>
    <body>
        <div id="info">
            Click to add/remove blocks<br>
            WASD to move, Space to jump, Mouse to look around
        </div>
    
        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/PointerLockControls.min.js"></script>
        <script>
            // Initialize Three.js
            const scene = new THREE.Scene();
            scene.background = new THREE.Color(0x87CEEB); // Sky blue
            
            const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            const renderer = new THREE.WebGLRenderer();
            renderer.setSize(window.innerWidth, window.innerHeight);
            document.body.appendChild(renderer.domElement);
            
            // Lighting
            const ambientLight = new THREE.AmbientLight(0x404040);
            scene.add(ambientLight);
            
            const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
            directionalLight.position.set(1, 1, 1);
            scene.add(directionalLight);
            
            // Controls
            const controls = new THREE.PointerLockControls(camera, document.body);
            
            document.addEventListener('click', function() {
                controls.lock();
            });
            
            // Add a floor
            const floorGeometry = new THREE.PlaneGeometry(100, 100, 1, 1);
            const floorMaterial = new THREE.MeshLambertMaterial({ color: 0x44aa44 }); // Green
            const floor = new THREE.Mesh(floorGeometry, floorMaterial);
            floor.rotation.x = -Math.PI / 2;
            floor.position.y = -0.5;
            scene.add(floor);
            
            // Block materials
            const blockTypes = {
                dirt: new THREE.MeshLambertMaterial({ color: 0x8B4513 }),
                grass: new THREE.MeshLambertMaterial({ color: 0x7CFC00 }),
                stone: new THREE.MeshLambertMaterial({ color: 0x808080 }),
                wood: new THREE.MeshLambertMaterial({ color: 0x8B7355 })
            };
            
            let currentBlockType = 'dirt';
            
            // Create a cube geometry (shared by all blocks)
            const blockGeometry = new THREE.BoxGeometry(1, 1, 1);
            
            // Store all blocks in a map
            const blocks = new Map();
            
            // Generate initial world
            function generateWorld() {
                // Create a flat terrain with some random blocks
                for (let x = -10; x <= 10; x++) {
                    for (let z = -10; z <= 10; z++) {
                        // Create ground layer
                        createBlock(x, -1, z, 'grass');
                        
                        // Randomly add some blocks above ground
                        if (Math.random() < 0.1) {
                            const height = Math.floor(Math.random() * 3) + 1;
                            for (let y = 0; y < height; y++) {
                                const type = Math.random() < 0.5 ? 'dirt' : 'stone';
                                createBlock(x, y, z, type);
                            }
                        }
                    }
                }
            }
            
            // Create a block at position
            function createBlock(x, y, z, type) {
                const position = `${x},${y},${z}`;
                
                // Don't create if block already exists
                if (blocks.has(position)) return;
                
                const material = blockTypes[type] || blockTypes.dirt;
                const cube = new THREE.Mesh(blockGeometry, material);
                cube.position.set(x, y, z);
                
                scene.add(cube);
                blocks.set(position, { mesh: cube, type });
            }
            
            // Remove a block at position
            function removeBlock(x, y, z) {
                const position = `${x},${y},${z}`;
                const block = blocks.get(position);
                
                if (block) {
                    scene.remove(block.mesh);
                    blocks.delete(position);
                }
            }
            
            // Raycasting for block selection
            const raycaster = new THREE.Raycaster();
            const mouse = new THREE.Vector2();
            
            // Block placement and removal
            window.addEventListener('mousedown', (event) => {
                if (!controls.isLocked) return;
                
                raycaster.setFromCamera(new THREE.Vector2(0, 0), camera);
                
                const intersects = raycaster.intersectObjects(Array.from(blocks.values()).map(b => b.mesh));
                
                if (intersects.length > 0) {
                    const intersect = intersects[0];
                    
                    // Left click to remove block
                    if (event.button === 0) {
                        const position = intersect.object.position;
                        removeBlock(position.x, position.y, position.z);
                    }
                    
                    // Right click to add block
                    else if (event.button === 2) {
                        // Calculate position based on face
                        const position = intersect.object.position.clone();
                        const face = intersect.face.normal;
                        
                        position.x += face.x;
                        position.y += face.y;
                        position.z += face.z;
                        
                        createBlock(position.x, position.y, position.z, currentBlockType);
                    }
                }
            });
            
            // Prevent context menu on right click
            window.addEventListener('contextmenu', (event) => {
                event.preventDefault();
            });
            
            // Change block type with keys 1-4
            window.addEventListener('keydown', (event) => {
                switch (event.key) {
                    case '1': currentBlockType = 'dirt'; break;
                    case '2': currentBlockType = 'grass'; break;
                    case '3': currentBlockType = 'stone'; break;
                    case '4': currentBlockType = 'wood'; break;
                }
            });
            
            // Movement controls
            const velocity = new THREE.Vector3();
            const moveForward = false, moveBackward = false, moveLeft = false, moveRight = false;
            
            document.addEventListener('keydown', (event) => {
                switch (event.code) {
                    case 'KeyW': moveForward = true; break;
                    case 'KeyA': moveLeft = true; break;
                    case 'KeyS': moveBackward = true; break;
                    case 'KeyD': moveRight = true; break;
                    case 'Space': if (canJump) velocity.y = 10; canJump = false; break;
                }
            });
            
            document.addEventListener('keyup', (event) => {
                switch (event.code) {
                    case 'KeyW': moveForward = false; break;
                    case 'KeyA': moveLeft = false; break;
                    case 'KeyS': moveBackward = false; break;
                    case 'KeyD': moveRight = false; break;
                }
            });
            
            // Physics variables
            let canJump = true;
            const direction = new THREE.Vector3();
            const moveSpeed = 0.1;
            
            // Initialize game
            generateWorld();
            camera.position.set(0, 1, 5);
            
            // Animation loop
            const clock = new THREE.Clock();
            
            function animate() {
                requestAnimationFrame(animate);
                
                const delta = clock.getDelta();
                
                // Movement
                if (controls.isLocked) {
                    // Gravity
                    velocity.y -= 0.1;
                    
                    // Forward/backward
                    direction.z = Number(moveForward) - Number(moveBackward);
                    // Left/right
                    direction.x = Number(moveRight) - Number(moveLeft);
                    direction.normalize();
                    
                    if (moveForward || moveBackward) controls.moveForward(direction.z * moveSpeed);
                    if (moveLeft || moveRight) controls.moveRight(direction.x * moveSpeed);
                    
                    // Apply gravity
                    controls.getObject().position.y += velocity.y * delta;
                    
                    // Floor collision
                    if (controls.getObject().position.y < 1) {
                        velocity.y = 0;
                        controls.getObject().position.y = 1;
                        canJump = true;
                    }
                }
                
                renderer.render(scene, camera);
            }
            
            animate();
            
            // Handle window resizing
            window.addEventListener('resize', function() {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            });
        </script>
    </body>
    </html>
    

    Would you like me to explain or break down the code?

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