Skip to content
TheChatArchiveThe Chat Archive
Mistralmistral-medium-2505· Mistral AIHugging Face LMArena Human Preference 140K

📜 单页love2d lua 动画生成需求 📌 动画要求 - 项目形式:纯 lua文件 - 不使用任何外部库 - 页面尺寸:适合短视频平台展示(9:16) - 打开…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514’s answer.
  1. User

    📜 单页love2d lua 动画生成需求

        ### 📌 动画要求
        - **项目形式**:纯 lua文件 
        - **不使用任何外部库** 
        - **页面尺寸**:适合短视频平台展示(9:16)
        - **打开 游戏即开始动画** 
        - **不需要用户交互**
    
        ---
    
        ### 📌 动画内容
        - 要对观众有**吸引力**,有创意。
        - 碰撞的时候加上随机坐标偏移,防止死循环卡死
    
        ---
    
        ### 📌 动画效果
        - 必须加入适当的视觉效果:
          - 拖尾
          - 随时间变色
          - 动态变速、动态变化属性
    
        ---
    
        ### 📌 状态展示
        - **页面上实时显示当前状态**,例如:
          - 当前小球数量
          - 当前小球平均速度
          - 其他关键数值/趋势
    
        ---
    
        ### 📌 运行与循环
        - 动画有**明确的结束条件**
          - 例如超出界限、超时、球数达500个上限、速度过快等
    	- 要考虑很多特殊情况,比如所有小球飞出屏幕外。
        - 结束后自动重新开始(不需要显示什么game over,游戏结束界面,不等待直接重开)
    
    
    
        ---
    
        ### 📌 最后
        - 只需要输出 lua代码块 
    	- 脚本不需要输出注释
        - 不需要其他解释说明或引导文字
    
    	### 需要做出的主题::绘制一个物理模拟,底部有一个固定平台,上方自动堆叠方块。每个新方块随机位置落在塔顶,受重力影响。塔的倾斜角度超过45度或方块掉落超过10个时结束。代码无外部依赖。
    
  2. Mistral Assistant
    function love.load()
        love.window.setMode(720, 1280)
        love.graphics.setBackgroundColor(0.1, 0.1, 0.2)
        math.randomseed(os.time())
        reset()
    end
    
    function reset()
        blocks = {}
        fallenCount = 0
        maxBlocks = 100
        blockSize = 40
        platformHeight = 1200
        gravity = 0.5
        friction = 0.98
        elasticity = 0.6
        spawnTimer = 0
        spawnInterval = 0.5
        gameTime = 0
        colors = {
            {1, 0.2, 0.2},
            {0.2, 1, 0.2},
            {0.2, 0.2, 1},
            {1, 1, 0.2},
            {1, 0.2, 1},
            {0.2, 1, 1}
        }
        addPlatform()
    end
    
    function addPlatform()
        table.insert(blocks, {
            x = 360 - blockSize * 5,
            y = platformHeight,
            w = blockSize * 10,
            h = blockSize,
            vx = 0,
            vy = 0,
            fixed = true,
            color = {0.5, 0.5, 0.5},
            trails = {}
        })
    end
    
    function spawnBlock()
        if #blocks >= maxBlocks then return end
        local topBlock = nil
        local maxY = -math.huge
        for _, b in ipairs(blocks) do
            if not b.fixed and b.y > maxY then
                maxY = b.y
                topBlock = b
            end
        end
        local x = math.random(360 - blockSize * 2, 360 + blockSize * 2)
        local y = topBlock and topBlock.y - blockSize or platformHeight - blockSize * 2
        local color = colors[math.random(1, #colors)]
        table.insert(blocks, {
            x = x,
            y = y,
            w = blockSize,
            h = blockSize,
            vx = 0,
            vy = 0,
            fixed = false,
            color = color,
            trails = {},
            age = 0
        })
    end
    
    function updateBlocks(dt)
        for i, block in ipairs(blocks) do
            if not block.fixed then
                block.vy = block.vy + gravity
                block.x = block.x + block.vx * dt
                block.y = block.y + block.vy * dt
                block.vx = block.vx * friction
                block.vy = block.vy * friction
                block.age = block.age + dt
                table.insert(block.trails, 1, {x = block.x, y = block.y, age = 0})
                if #block.trails > 10 then
                    table.remove(block.trails)
                end
                for _, t in ipairs(block.trails) do
                    t.age = t.age + dt
                end
            end
        end
        for i = 1, #blocks do
            for j = i + 1, #blocks do
                local a, b = blocks[i], blocks[j]
                if checkCollision(a, b) then
                    resolveCollision(a, b)
                end
            end
        end
        for i = #blocks, 1, -1 do
            local block = blocks[i]
            if not block.fixed and (block.y > love.graphics.getHeight() or block.x < -block.w or block.x > love.graphics.getWidth()) then
                table.remove(blocks, i)
                fallenCount = fallenCount + 1
            end
        end
    end
    
    function checkCollision(a, b)
        return not (a.x + a.w < b.x or a.x > b.x + b.w or a.y + a.h < b.y or a.y > b.y + b.h)
    end
    
    function resolveCollision(a, b)
        if a.fixed and b.fixed then return end
        local ax1, ay1 = a.x + a.w/2, a.y + a.h/2
        local ax2, ay2 = a.x + a.w/2, a.y + a.h/2
        local bx1, by1 = b.x + b.w/2, b.y + b.h/2
        local bx2, by2 = b.x + b.w/2, b.y + b.h/2
        local nx = (ax1 + ax2)/2 - (bx1 + bx2)/2
        local ny = (ay1 + ay2)/2 - (by1 + by2)/2
        local n = math.sqrt(nx * nx + ny * ny)
        if n == 0 then return end
        nx, ny = nx/n, ny/n
        local tx = -ny
        local ty = nx
        local dp1 = (a.x + a.w/2 - b.x - b.w/2) * tx + (a.y + a.h/2 - b.y - b.h/2) * ty
        local dp2 = (a.x + a.w/2 - b.x - b.w/2) * nx + (a.y + a.h/2 - b.y - b.h/2) * ny
        local sign = dp2 > 0 and 1 or -1
        local penetration = (a.w + b.w)/2 - math.abs(dp1)
        if penetration > 0 then
            local moveX = tx * penetration * 0.5 * sign
            local moveY = ty * penetration * 0.5 * sign
            if not a.fixed then
                a.x = a.x + moveX
                a.y = a.y + moveY
            end
            if not b.fixed then
                b.x = b.x - moveX
                b.y = b.y - moveY
            end
        end
        local v1 = math.sqrt(a.vx * a.vx + a.vy * a.vy)
        local v2 = math.sqrt(b.vx * b.vx + b.vy * b.vy)
        local dir1 = math.atan2(a.vy, a.vx)
        local dir2 = math.atan2(b.vy, b.vx)
        local m1 = a.w * a.h
        local m2 = b.w * b.h
        local newV1 = (v1 * (m1 - m2) + 2 * m2 * v2) / (m1 + m2) * elasticity
        local newV2 = (v2 * (m2 - m1) + 2 * m1 * v1) / (m1 + m2) * elasticity
        if not a.fixed then
            a.vx = newV1 * math.cos(dir1) + math.random() - 0.5
            a.vy = newV1 * math.sin(dir1) + math.random() - 0.5
        end
        if not b.fixed then
            b.vx = newV2 * math.cos(dir2) + math.random() - 0.5
            b.vy = newV2 * math.sin(dir2) + math.random() - 0.5
        end
    end
    
    function checkGameOver()
        if fallenCount >= 10 then return true end
        local topBlocks = {}
        for _, b in ipairs(blocks) do
            if not b.fixed and b.y < platformHeight - blockSize * 2 then
                table.insert(topBlocks, b)
            end
        end
        if #topBlocks < 3 then return false end
        local leftmost = math.huge
        local rightmost = -math.huge
        for _, b in ipairs(topBlocks) do
            if b.x < leftmost then leftmost = b.x end
            if b.x + b.w > rightmost then rightmost = b.x + b.w end
        end
        local center = (leftmost + rightmost) / 2
        local angle = math.atan2(platformHeight - (topBlocks[1].y + topBlocks[1].h), center - (topBlocks[1].x + topBlocks[1].w/2))
        return math.abs(angle) > math.pi/4
    end
    
    function love.update(dt)
        gameTime = gameTime + dt
        spawnTimer = spawnTimer + dt
        if spawnTimer > spawnInterval then
            spawnTimer = 0
            spawnBlock()
        end
        updateBlocks(dt)
        if checkGameOver() then
            reset()
        end
    end
    
    function love.draw()
        for _, block in ipairs(blocks) do
            for i, trail in ipairs(block.trails) do
                local alpha = 1 - trail.age / 0.5
                if alpha > 0 then
                    love.graphics.setColor(block.color[1], block.color[2], block.color[3], alpha * 0.5)
                    love.graphics.rectangle("fill", trail.x, trail.y, block.w, block.h)
                end
            end
            local hue = (math.sin(gameTime * 2 + block.age) + 1) / 2
            love.graphics.setColor(block.color[1] * hue, block.color[2] * hue, block.color[3] * hue)
            love.graphics.rectangle("fill", block.x, block.y, block.w, block.h)
        end
        love.graphics.setColor(1, 1, 1)
        love.graphics.print("Blocks: " .. (#blocks - 1), 10, 10)
        love.graphics.print("Fallen: " .. fallenCount, 10, 30)
        local totalSpeed = 0
        local movingBlocks = 0
        for _, b in ipairs(blocks) do
            if not b.fixed then
                totalSpeed = totalSpeed + math.sqrt(b.vx * b.vx + b.vy * b.vy)
                movingBlocks = movingBlocks + 1
            end
        end
        local avgSpeed = movingBlocks > 0 and totalSpeed / movingBlocks or 0
        love.graphics.print(string.format("Avg Speed: %.2f", avgSpeed), 10, 50)
        love.graphics.print(string.format("Tower Angle: %.1f°", getTowerAngle()), 10, 70)
    end
    
    function getTowerAngle()
        local topBlocks = {}
        for _, b in ipairs(blocks) do
            if not b.fixed and b.y < platformHeight - blockSize * 2 then
                table.insert(topBlocks, b)
            end
        end
        if #topBlocks < 2 then return 0 end
        local leftmost = math.huge
        local rightmost = -math.huge
        for _, b in ipairs(topBlocks) do
            if b.x < leftmost then leftmost = b.x end
            if b.x + b.w > rightmost then rightmost = b.x + b.w end
        end
        local center = (leftmost + rightmost) / 2
        local angle = math.atan2(platformHeight - (topBlocks[1].y + topBlocks[1].h), center - (topBlocks[1].x + topBlocks[1].w/2))
        return math.deg(angle)
    end
    

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