Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-5-sonnet-20241022· AnthropicHugging Face LMArena Human Preference 140K

A 3D planet generator game using 3 types of voxels for terrain, water, sand and grass,…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-4-maverick-17b-128e-instruct’s answer.
  1. User

    A 3D planet generator game using 3 types of voxels for terrain, water, sand and grass, the player is in a flying god like state with basic controls, and the background is space and a sun that points light at the planet, the planet is also procedurally generated.

  2. Claude Assistant

    I'll help you create a basic 3D planet generator game using Unity. Here's a solution broken down into key components:

    // PlanetGenerator.cs
    using UnityEngine;
    
    public class PlanetGenerator : MonoBehaviour 
    {
        [SerializeField] private GameObject waterVoxel;
        [SerializeField] private GameObject sandVoxel;
        [SerializeField] private GameObject grassVoxel;
        [SerializeField] private int planetRadius = 10;
        [SerializeField] private float noiseScale = 10f;
        
        private void Start()
        {
            GeneratePlanet();
        }
    
        private void GeneratePlanet()
        {
            for (float x = -planetRadius; x <= planetRadius; x++)
            {
                for (float y = -planetRadius; y <= planetRadius; y++)
                {
                    for (float z = -planetRadius; z <= planetRadius; z++)
                    {
                        Vector3 position = new Vector3(x, y, z);
                        float distanceFromCenter = position.magnitude;
                        
                        if (distanceFromCenter <= planetRadius)
                        {
                            float noise = Mathf.PerlinNoise((x + 0.1f) / noiseScale, (z + 0.1f) / noiseScale);
                            SpawnVoxel(position, noise);
                        }
                    }
                }
            }
        }
    
        private void SpawnVoxel(Vector3 position, float noise)
        {
            GameObject voxelType;
            
            if (noise < 0.3f)
                voxelType = waterVoxel;
            else if (noise < 0.6f)
                voxelType = sandVoxel;
            else
                voxelType = grassVoxel;
    
            Instantiate(voxelType, position, Quaternion.identity, transform);
        }
    }
    
    // PlayerController.cs
    public class PlayerController : MonoBehaviour
    {
        [SerializeField] private float moveSpeed = 10f;
        [SerializeField] private float rotateSpeed = 100f;
        
        private void Update()
        {
            // Basic WASD movement
            float horizontal = Input.GetAxis("Horizontal");
            float vertical = Input.GetAxis("Vertical");
            float up = Input.GetKey(KeyCode.Space) ? 1 : 0;
            float down = Input.GetKey(KeyCode.LeftShift) ? -1 : 0;
    
            Vector3 movement = new Vector3(horizontal, up + down, vertical) * moveSpeed * Time.deltaTime;
            transform.Translate(movement);
    
            // Mouse look
            float mouseX = Input.GetAxis("Mouse X");
            float mouseY = Input.GetAxis("Mouse Y");
            
            transform.Rotate(Vector3.up, mouseX * rotateSpeed * Time.deltaTime);
            transform.Rotate(Vector3.right, -mouseY * rotateSpeed * Time.deltaTime);
        }
    }
    

    To implement this:

    1. Create three voxel prefabs (water, sand, grass) as simple cubes with different materials
    2. Create a new empty GameObject and attach the PlanetGenerator script
    3. Assign the voxel prefabs in the inspector
    4. Create a camera object and attach the PlayerController script
    5. Add a directional light for the sun
    6. Set up a skybox material with a space theme

    Key features:

    • Procedural planet generation using Perlin noise
    • Three types of voxels (water, sand, grass)
    • Flying camera controls (WASD + Space/Shift + Mouse)
    • Spherical planet shape

    To enhance this basic version, you could add:

    • Chunk loading for better performance
    • More varied terrain using multiple noise layers
    • Voxel destruction/placement
    • Atmosphere effects
    • Planet rotation
    • Multiple biomes

    Would you like me to elaborate on any of these aspects or explain how to implement additional features?

  3. User

    Make it into just HTML, JS and CSS (for codepen/codepen compatible)

  4. Claude Assistant

    Here's a simplified version using Three.js for WebGL rendering:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Voxel Planet Generator</title>
        <style>
            body { 
                margin: 0;
                overflow: hidden;
            }
            canvas { 
                width: 100%;
                height: 100%;
            }
        </style>
    </head>
    <body>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
        <script>
            let scene, camera, renderer;
            let planet;
            const planetRadius = 10;
            const noiseScale = 10;
    
            function init() {
                // Setup scene
                scene = new THREE.Scene();
                camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
                renderer = new THREE.WebGLRenderer();
                renderer.setSize(window.innerWidth, window.innerHeight);
                document.body.appendChild(renderer.domElement);
    
                // Add lighting
                const light = new THREE.DirectionalLight(0xffffff, 1);
                light.position.set(50, 50, 50);
                scene.add(light);
                scene.add(new THREE.AmbientLight(0x404040));
    
                // Setup camera position
                camera.position.z = 30;
    
                // Generate planet
                generatePlanet();
    
                // Add stars
                addStars();
    
                // Start animation loop
                animate();
    
                // Add controls
                document.addEventListener('keydown', handleKeyDown);
                document.addEventListener('mousemove', handleMouseMove);
            }
    
            function generatePlanet() {
                planet = new THREE.Group();
                
                // Materials for different voxel types
                const materials = {
                    water: new THREE.MeshPhongMaterial({ color: 0x0077be }),
                    sand: new THREE.MeshPhongMaterial({ color: 0xc2b280 }),
                    grass: new THREE.MeshPhongMaterial({ color: 0x567d46 })
                };
    
                const voxelGeometry = new THREE.BoxGeometry(1, 1, 1);
    
                for (let x = -planetRadius; x <= planetRadius; x++) {
                    for (let y = -planetRadius; y <= planetRadius; y++) {
                        for (let z = -planetRadius; z <= planetRadius; z++) {
                            const position = new THREE.Vector3(x, y, z);
                            if (position.length() <= planetRadius) {
                                // Simple noise function for demonstration
                                const noise = Math.abs(Math.sin(x/noiseScale) * Math.cos(z/noiseScale));
                                let material;
    
                                if (noise < 0.3) material = materials.water;
                                else if (noise < 0.6) material = materials.sand;
                                else material = materials.grass;
    
                                const voxel = new THREE.Mesh(voxelGeometry, material);
                                voxel.position.set(x, y, z);
                                planet.add(voxel);
                            }
                        }
                    }
                }
    
                scene.add(planet);
            }
    
            function addStars() {
                const starGeometry = new THREE.BufferGeometry();
                const starMaterial = new THREE.PointsMaterial({
                    color: 0xFFFFFF,
                    size: 0.1
                });
    
                const starVertices = [];
                for (let i = 0; i < 10000; i++) {
                    const x = (Math.random() - 0.5) * 2000;
                    const y = (Math.random() - 0.5) * 2000;
                    const z = (Math.random() - 0.5) * 2000;
                    starVertices.push(x, y, z);
                }
    
                starGeometry.setAttribute('position', 
                    new THREE.Float32BufferAttribute(starVertices, 3));
                const stars = new THREE.Points(starGeometry, starMaterial);
                scene.add(stars);
            }
    
            // Camera controls
            const moveSpeed = 0.5;
            const rotateSpeed = 0.01;
    
            function handleKeyDown(event) {
                switch(event.key) {
                    case 'w': camera.position.z -= moveSpeed; break;
                    case 's': camera.position.z += moveSpeed; break;
                    case 'a': camera.position.x -= moveSpeed; break;
                    case 'd': camera.position.x += moveSpeed; break;
                    case ' ': camera.position.y += moveSpeed; break;
                    case 'Shift': camera.position.y -= moveSpeed; break;
                }
            }
    
            function handleMouseMove(event) {
                if (event.buttons === 1) { // Left mouse button
                    camera.rotation.y += event.movementX * rotateSpeed;
                    camera.rotation.x += event.movementY * rotateSpeed;
                }
            }
    
            function animate() {
                requestAnimationFrame(animate);
                planet.rotation.y += 0.001;
                renderer.render(scene, camera);
            }
    
            // Handle window resize
            window.addEventListener('resize', onWindowResize, false);
    
            function onWindowResize() {
                camera.aspect = window.innerWidth / window.innerHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(window.innerWidth, window.innerHeight);
            }
    
            // Start the application
            init();
        </script>
    </body>
    </html>
    

    This code creates a simple voxel planet generator with:

    • Three types of voxels (water, sand, grass)
    • Basic WASD + Space/Shift movement controls
    • Mouse drag rotation
    • Starfield background
    • Slow planet rotation
    • Dynamic lighting

    To use this:

    1. Copy the code into a new HTML file
    2. Open in a modern browser
    3. Use WASD to move, Space/Shift for up/down
    4. Click and drag to rotate the view

    The planet is generated using a simple noise function. For more realistic terrain, you could:

    • Implement proper Perlin noise
    • Add more biome types
    • Improve the lighting system
    • Add atmosphere effects
    • Implement chunk loading for better performance

    Would you like me to explain any part in more detail or show how to implement any of these improvements?

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