Skip to content
TheChatArchiveThe Chat Archive
Metallama-3.3-70b-instruct· MetaHugging Face LMArena Human Preference 140K

I forgot to say the nodes will be inside predetermined rooms since the map will br…

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

    I forgot to say the nodes will be inside predetermined rooms since the map will br rsndomly generated, this means it has a certain ampunt of rooms but can be set up in a random order so there wont be a nodes folder

  2. Meta Assistant

    In that case, we can modify the script to find the nodes within the rooms instead of relying on a specific folder. Here's an updated version of the script:

    -- ServerScriptService.MonsterPathfinding
    
    local monster = workspace.Monster -- Make sure your monster model is named "Monster"
    local humanoid = monster:FindFirstChild("Humanoid")
    local root = monster:FindFirstChild("HumanoidRootPart")
    
    if not humanoid or not root then
        warn("Monster missing Humanoid or HumanoidRootPart")
        return
    end
    
    -- Function to find all nodes in the workspace
    local function getAllNodes()
        local nodes = {}
        for _, object in ipairs(workspace:GetDescendants()) do
            if object:IsA("BasePart") and object.Name == "PathNode" then
                table.insert(nodes, object)
            end
        end
        return nodes
    end
    
    -- Get closest unvisited node
    local function getClosestUnvisitedNode(currentPosition, visitedNodes)
        local minDistance = math.huge
        local closestNode = nil
        local nodes = getAllNodes()
    
        for _, node in ipairs(nodes) do
            if not visitedNodes[node] then
                local distance = (node.Position - currentPosition).Magnitude
                if distance < minDistance then
                    minDistance = distance
                    closestNode = node
                end
            end
        end
    
        return closestNode
    end
    
    -- Simulate leaving an ability (can be expanded later)
    local function leaveAbilityAtNode(node)
        if math.random() < 0.5 then -- 50% chance to leave ability
            print(monster.Name .. " left an ability at " .. node.Name)
        end
    end
    
    -- Main movement loop
    local visitedNodes = {}
    
    while true do
        local currentNode = getClosestUnvisitedNode(root.Position, visitedNodes)
        
        if not currentNode then
            print("All nodes visited.")
            break
        end
    
        visitedNodes[currentNode] = true
    
        -- Move to node
        local path = game:GetService("PathfindingService"):CreatePath({
            AgentHeight = 5,
            AgentRadius = 2,
            AgentCanJump = false,
        })
    
        path:ComputeAsync(root.Position, currentNode.Position)
    
        if path.Status == Enum.PathStatus.Success then
            local waypoints = path:GetWaypoints()
            for _, waypoint in ipairs(waypoints) do
                humanoid:MoveTo(waypoint.Position)
                humanoid.MoveToFinished:Wait()
            end
    
            leaveAbilityAtNode(currentNode)
        else
            warn("Could not compute path to node:", currentNode.Name)
        end
    
        wait(1) -- Optional delay before next move
    end
    

    In this version, the getAllNodes function searches through all objects in the workspace to find parts named "PathNode". This way, you can place the path nodes anywhere in the workspace, and the script will still be able to find them.

    Alternatively, if you want to make sure the script only finds nodes within certain rooms, you could modify the getAllNodes function to only search within certain models or folders. For example:

    -- Function to find all nodes in the workspace
    local function getAllNodes()
        local nodes = {}
        for _, room in ipairs(workspace:GetChildren()) do
            if room:IsA("Model") and room.Name:match("Room") then
                for _, object in ipairs(room:GetDescendants()) do
                    if object:IsA("BasePart") and object.Name == "PathNode" then
                        table.insert(nodes, object)
                    end
                end
            end
        end
        return nodes
    end
    

    This version of the function only searches for nodes within models named "Room" or similar (e.g. "Room1", "Room2", etc.). You can adjust the room.Name:match("Room") line to match the names of your room models.

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