Adaptivity AI
Key RequiredUniversal

Adaptivity AI

Universal Scripttazgamerz7867tazgamerz7867 745 views 67 executesUpdated May 13, 2026
0.0/ 5(1 votes)
010% Positive
Lua Script•607 lines (36516 chars)
--[[
🧠 AdaptivityAI V1 - Self-Learning Roblox AI Companion
Author: AdaptivityAI Team
Version: 1.0.0
Platform: PC & Mobile | Executor: Synapse, KRNL, Fluxus, Hydrogen, Delta, Codex, etc.
License: Free for personal use. Do not claim as your own.

šŸ“¦ FEATURES:
- Observer Mode (learns from you + passive server activity)
- Crowd Observe (Clone-only curious learning + player tracking)
- Ghost / Lend Modes (confidence-gated autonomous replay)
- Pseudo-Quadratic Learning Engine (pattern reinforcement, spatial decay, confidence scaling)
- 10-Layer Performance Stack (budget throttle, spatial hash, delta compression, LOD, coroutine pooling)
- Token & Confidence System (gates actions, prevents bloat, live UI bars)
- Vision Raycasting + Workspace Scanner + Logic Simulator
- Prediction, Urgency, Goals, Macros, Anomalies, Forgetting Curve
- Light/Dark UI (draggable, resizable, zero camera hijack)
- Multi-Brain Profiles, Chat Commands, Keybinds, Mobile Support

āŒØļø KEYBINDS (PC):
G = Toggle Observer | H = Toggle Ghost | J = Toggle GUI | F = Reclaim Control

šŸ’¬ CHAT COMMANDS (/adapt <cmd>):
learn, stop, ghost, lend, reclaim, pause, save, tokens, theme, crowd, scan, triggers, status, help

āš ļø NOTES:
- Fully client-side. Does not read ServerScriptService (Roblox security limitation).
- Learns by observing inputs, proximity prompts, remotes, and player behavior.
- Confidence must reach ~25% before Ghost/Lend will spawn.
- Runs on a single budgeted heartbeat (~2ms/frame cap). Potato-friendly.
]]

-- ============================================================
-- SECTION 1: SERVICES & PLATFORM
-- ============================================================
local Players      = game:GetService("Players")
local RunService   = game:GetService("RunService")
local UserInput    = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local HttpService  = game:GetService("HttpService")
local Pathfinding  = game:GetService("PathfindingService")
local LocalPlayer  = Players.LocalPlayer
local PlayerGui    = LocalPlayer:WaitForChild("PlayerGui")
local isMobile     = UserInput.TouchEnabled and not UserInput.KeyboardEnabled

-- ============================================================
-- SECTION 2: EXECUTOR COMPATIBILITY LAYER
-- ============================================================
local Exec = {}
function Exec.read(p)    if readfile  then local o,r=pcall(readfile,p); return o and r end return nil end
function Exec.write(p,d) if writefile then pcall(writefile,p,d); return true end return false end
function Exec.isFile(p)  if isfile    then local o,r=pcall(isfile,p); return o and r end return false end
function Exec.isDir(p)   if isfolder  then local o,r=pcall(isfolder,p); return o and r end return false end
function Exec.makeDir(p) if makefolder and not Exec.isDir(p) then pcall(makefolder,p) end end
function Exec.fire(btn)  if btn and btn:IsA("GuiButton") then pcall(btn.FireMouseButton1Click, btn) end end
function Exec.http(url,h,b)
	if syn and syn.request then local o,r=pcall(syn.request,{Url=url,Method="POST",Headers=h,Body=b}); if o then return r end end
	if request then local o,r=pcall(request,{Url=url,Method="POST",Headers=h,Body=b}); if o then return r end end
	local o,r=pcall(HttpService.RequestAsync,HttpService,{Url=url,Method="POST",Headers=h,Body=b}); return o and r
end

-- ============================================================
-- SECTION 3: PERFORMANCE ENGINE (10-LAYER)
-- ============================================================
local Perf = {
   budgetMs = 2.0, lastFrame = 0, tickAcc = 0,
   tier = 3, -- 1=High, 2=Mid, 3=Low, 4=Potato, 5=Nuclear
   spatialGrid = {}, cellSize = 16,
   deltaCache = {}, lastWrite = 0,
   asyncQueue = {}, coroutinePool = {},
   lodBands = {near=20, mid=50, far=100},
   memThreshold = 500, gcTimer = 0
}
function Perf.profileTier()
   local fps = 60; local ping = 0; local mem = gcinfo()
   if fps>50 and ping<80 and mem<200 then Perf.tier=1
   elseif fps>40 and ping<150 and mem<350 then Perf.tier=2
   elseif fps>25 and ping<300 and mem<500 then Perf.tier=3
   elseif fps>15 and ping<500 and mem<700 then Perf.tier=4
   else Perf.tier=5 end
   Perf.cellSize = Perf.tier<=2 and 8 or (Perf.tier==3 and 16 or 32)
   Perf.lodBands = Perf.tier<=2 and {near=30,mid=60,far=120} or {near=15,mid=35,far=70}
end
function Perf.spatialHash(pos)
   return math.floor(pos.X / Perf.cellSize).."_"..math.floor(pos.Z / Perf.cellSize)
end
function Perf.deltaCompress(key, newData)
   local old = Perf.deltaCache[key]
   if not old then Perf.deltaCache[key]=newData; return newData end
   local delta = {}
   for k,v in pairs(newData) do if old[k]~=v then delta[k]=v end end
   Perf.deltaCache[key]=newData
   return next(delta) and delta or nil
end
function Perf.asyncWrite(fn)
   table.insert(Perf.asyncQueue, fn)
   if #Perf.coroutinePool < (Perf.tier<=3 and 3 or 1) then
      local co = coroutine.create(function()
         while true do
            if #Perf.asyncQueue>0 then pcall(table.remove(Perf.asyncQueue,1)) end
            coroutine.yield()
         end
      end)
      table.insert(Perf.coroutinePool, co)
   end
end
function Perf.budgetCheck(start)
   return (os.clock()-start)*1000 < Perf.budgetMs
end
function Perf.memoryGuard()
   Perf.gcTimer += 1
   if Perf.gcTimer >= 600 then
      Perf.gcTimer = 0
      if gcinfo() > Perf.memThreshold then
         collectgarbage("collect")
      end
   end
end

-- ============================================================
-- SECTION 4: PSEUDO-QUADRATIC LEARNING ENGINE
-- ============================================================
local Quad = {}
-- Quadratic pattern reinforcement: weight accelerates with repetition
function Quad.reinforce(base, count, mult)
   return base + (count^2 * (mult or 0.5))
end
-- Quadratic spatial decay: influence drops with distance^2
function Quad.spatialInfluence(dist, scale)
   return 1 / (1 + (dist^2 / (scale or 100)))
end
-- Quadratic confidence scaling: smooth curve that accelerates then caps
function Quad.confidence(actions, sessions)
   local raw = (actions^2 * 0.015) + (sessions * 8)
   return math.min(100, math.max(0, raw))
end
-- Quadratic learning rate: scales with session density
function Quad.learningRate(density, baseRate)
   local clamped = math.min(density, 50)
   return baseRate * (1 + (clamped^2 * 0.002))
end
-- Quadratic threat weighting: nearby threats scale aggressively
function Quad.threatWeight(dist, base)
   return base * (1 / (1 + (dist^2 * 0.01)))
end

-- ============================================================
-- SECTION 5: TOKEN & CONFIDENCE SYSTEM
-- ============================================================
local Tokens = { cur=0, max=500, regen=0.8, cost={rec=0.4,save=5,clone=2,predict=0.5} }
function Tokens.regen(dt) Tokens.cur=math.min(Tokens.max,Tokens.cur+Tokens.regen*dt) end
function Tokens.spend(a) if Tokens.cur<a then return false end; Tokens.cur-=a; return true end

local Confidence = {}
function Confidence.calc(actions, sessions)
   return Quad.confidence(actions or 0, sessions or 0)
end

-- ============================================================
-- SECTION 6: BRAIN & PERSISTENCE
-- ============================================================
local BD="AdaptivityAI"; Exec.makeDir(BD)
local Brain={v="1.0",places={},cfg={theme="light",tokens=500,keys={reclaim="F",toggle="G",ghost="H",gui="J"}}}
local getPid=tostring(game.PlaceId)
local function getGame() local s,e=pcall(function() return game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name end); return s and e or "Unknown" end
local function ensurePlace() if not Brain.places[getPid] then Brain.places[getPid]={name=getGame(),sess={},mental={},conf={move=0,ui=0,seq=0},updated=os.time()} end; return Brain.places[getPid] end
local function loadBrain()
   local p=BD.."/brain_"..getPid..".json"; if Exec.isFile(p) then local r=Exec.read(p); if r then local o,d=pcall(HttpService.JSONDecode,HttpService,r); if o then Brain=d; return true end end end
   return false
end
local function saveBrain()
   local pl=ensurePlace(); pl.updated=os.time()
   if Tokens.cur<Tokens.max*0.2 then
      table.sort(pl.sess,function(a,b) return Confidence.calc(#(a.actions or {}),1)>Confidence.calc(#(b.actions or {}),1) end)
      local keep=math.max(3,math.floor(#pl.sess*0.7)); for i=#pl.sess,keep+1,-1 do table.remove(pl.sess,i) end
      Tokens.cur=math.min(Tokens.max,Tokens.cur+50)
   end
   Tokens.spend(Tokens.cost.save)
   local ok,e=pcall(HttpService.JSONEncode,HttpService,Brain); if ok then Exec.write(BD.."/brain_"..getPid..".json",e) end
end

-- ============================================================
-- SECTION 7: AI STATE & OBSERVER MODE
-- ============================================================
local AI={mode="idle",learning=false,paused=false,persona="Mirror"}
local Observer={lastPos=Vector3.new(0,0,0),sess=nil,active=false}
function Observer.start()
   if Observer.active then return end
   Observer.active=true; AI.learning=true; AI.mode="observing"
   Observer.sess={id=os.time(),type="self",actions={},mov={},start=os.time()}
   Tokens.cur=Tokens.max; UI.toast("šŸ‘ Observer ON (Learning from you + server)")
end
function Observer.stop()
   if not Observer.active then return end
   Observer.active=false; AI.learning=false; AI.mode="idle"
   local p=ensurePlace()
   if Observer.sess and #Observer.sess.actions>2 then table.insert(p.sess,Observer.sess) end
   Observer.sess=nil; saveBrain(); UI.toast("šŸ‘ Observer OFF | Brain saved")
end
function Observer.rec(pos,act,data)
   if not Observer.sess or Tokens.cur<Tokens.cost.rec then return end
   Tokens.spend(Tokens.cost.rec)
   table.insert(Observer.sess.actions,{type=act,t=os.time()-Observer.sess.start,data=data or {x=pos.X,y=pos.Y,z=pos.Z}})
   if act=="move" then
      table.insert(Observer.sess.mov,{x=pos.X,y=pos.Y,z=pos.Z})
      local k=Perf.spatialHash(pos); local p=ensurePlace()
      if not p.mental[k] then p.mental[k]={x=pos.X,y=pos.Y,z=pos.Z,visits=1,tag="visited"}
      else p.mental[k].visits+=1; if p.mental[k].visits>5 then p.mental[k].tag="safe" end end
   end
end

-- ============================================================
-- SECTION 8: CROWD OBSERVE & CLONE CURIOSITY ENGINE
-- ============================================================
local Clone={model=nil,active=false,curious=false,trackers={},sess=nil,afk=0,path=nil,stepIdx=1,stuckTimer=0,lastPos=Vector3.new(0,0,0)}
function Clone.crowdTick(dt)
   if not Clone.active or not Clone.curious then return end
   Clone.afk+=dt
   for _,p in ipairs(Players:GetPlayers()) do
      if p==LocalPlayer or not p.Character then continue end
      local h=p.Character:FindFirstChild("HumanoidRootPart"); if not h then continue end
      local k=Perf.spatialHash(h.Position)
      if not Clone.trackers[p.UserId] then Clone.trackers[p.UserId]=h.Position end
      if (h.Position-Clone.trackers[p.UserId]).Magnitude>3 then
         Clone.trackers[p.UserId]=h.Position
         if Tokens.cur>Tokens.cost.rec then
            Tokens.spend(Tokens.cost.rec)
            table.insert(Clone.sess.actions,{type="crowd_move",t=os.time()-Clone.sess.start,data={x=h.Position.X,y=h.Position.Y,z=h.Position.Z}})
            local pl=ensurePlace()
            if not pl.mental[k] then pl.mental[k]={x=h.Position.X,y=h.Position.Y,z=h.Position.Z,visits=1,tag="crowd_visited"}
            else pl.mental[k].visits+=1 end
         end
      end
   end
   if Clone.afk>20 and #Clone.sess.actions>5 then
      table.insert(ensurePlace().sess,Clone.sess)
      Clone.sess={id=os.time(),type="crowd",actions={},start=os.time()}
      Clone.afk=0; saveBrain()
   end
end
function Clone.spawn()
   if Clone.model then pcall(Clone.model.Destroy,Clone.model) end
   local c=LocalPlayer.Character; if not c then return false end
   local g=c:Clone(); g.Name="AdaptivityAI_Clone"
   for _,v in ipairs(g:GetDescendants()) do if v:IsA("Script") or v:IsA("LocalScript") then v:Destroy() end end
   for _,p in ipairs(g:GetDescendants()) do if p:IsA("BasePart") then p.Transparency=0.55; p.CanCollide=false; p.Color=Color3.fromRGB(120,170,255); p.Material=Enum.Material.Neon end end
   local hrp,gr=c:FindFirstChild("HumanoidRootPart"),g:FindFirstChild("HumanoidRootPart")
   if hrp and gr then gr.CFrame=hrp.CFrame*CFrame.new(3,0,0) end
   g.Parent=workspace; Clone.model=g; return true
end
function Clone.startCurious()
   local p=ensurePlace()
   if not p or #p.sess==0 then UI.toast("āš ļø Observe first!"); return false end
   local avgConf=(p.conf.move+p.conf.ui+p.conf.seq)/3
   if avgConf<25 then UI.toast("āš ļø Confidence <25%. Observe more."); return false end
   if not Clone.spawn() then return false end
   Clone.active=true; Clone.curious=true; Clone.stepIdx=1; Clone.stuckTimer=0
   Clone.sess={id=os.time(),type="curious",actions={},start=os.time()}
   Clone.lastPos=Clone.model:FindFirstChild("HumanoidRootPart").Position
   AI.mode="curious_clone"; UI.toast("šŸ‘» Clone Spawned | Curious Learning ON")
   return true
end
function Clone.reclaim()
   Clone.active=false; Clone.curious=false; AI.mode="idle"
   if Clone.model then pcall(Clone.model.Destroy,Clone.model); Clone.model=nil end
   UI.toast("šŸ›‘ Clone Reclaimed")
end
function Clone.pickCuriousTarget()
   local p=ensurePlace(); local hrp=Clone.model and Clone.model:FindFirstChild("HumanoidRootPart")
   if not hrp then return nil end
   local best=nil, bestScore=-math.huge
   for k,lm in pairs(p.mental) do
      local pos=Vector3.new(lm.x,lm.y,lm.z)
      local dist=(hrp.Position-pos).Magnitude
      if dist>Perf.lodBands.near and dist<Perf.lodBands.far then
         local visits=lm.visits or 0
         local tag=lm.tag or "visited"
         local influence = Quad.spatialInfluence(dist, 80)
         local score = (tag=="danger" and -50 or 0) + (tag=="safe" and 10 or 0) + (visits<3 and 30 or 0) + (influence*20)
         if score>bestScore then bestScore=score; best=pos end
      end
   end
   return best or (hrp.CFrame.LookVector*20 + hrp.Position)
end
function Clone.executeMove(moveName, targetPos)
   local Moves = {walk_fwd={speed=16},jump={speed=16},sprint={speed=24},crouch={speed=8},flee={speed=26}}
   local m=Moves[moveName] or {speed=16}
   local hum=Clone.model and Clone.model:FindFirstChildOfClass("Humanoid")
   if not hum then return end
   hum.WalkSpeed=m.speed
   if targetPos then hum:MoveTo(targetPos) end
   if moveName=="jump" then hum.Jump=true end
end
function Clone.stepCurious(dt)
   if not Clone.active or not Clone.curious or AI.paused then return end
   local hrp=Clone.model and Clone.model:FindFirstChild("HumanoidRootPart")
   if not hrp then return end
   if (hrp.Position-Clone.lastPos).Magnitude<0.5 then
      Clone.stuckTimer+=dt
      if Clone.stuckTimer>1.5 then Clone.executeMove("jump"); Clone.stuckTimer=0; Clone.lastPos=hrp.Position; return end
   else Clone.stuckTimer=0; Clone.lastPos=hrp.Position end
   if not Clone.path or Clone.stepIdx>#Clone.path then
      local target=Clone.pickCuriousTarget()
      if target then
         local ok,path=pcall(Pathfinding.CreatePath,Pathfinding,{AgentRadius=2,AgentHeight=5,AgentCanJump=true})
         if ok and path then path:ComputeAsync(hrp.Position,target); Clone.path=path:GetWaypoints(); Clone.stepIdx=2
         else Clone.path={target}; Clone.stepIdx=1 end
      end
   end
   if Clone.path and Clone.stepIdx<=#Clone.path then
      local wp=Clone.path[Clone.stepIdx]
      Clone.executeMove("walk_fwd", wp.Position)
      if (hrp.Position-wp.Position).Magnitude<3 then Clone.stepIdx+=1 end
   end
   if Tokens.cur>Tokens.cost.rec and math.random()<0.3 then
      Tokens.spend(Tokens.cost.rec)
      table.insert(Clone.sess.actions,{type="curious_move",t=os.time()-Clone.sess.start,data={x=hrp.Position.X,y=hrp.Position.Y,z=hrp.Position.Z}})
   end
end

-- ============================================================
-- SECTION 9: VISION, WORKSPACE SCANNER & LOGIC SIMULATOR
-- ============================================================
local Vision = {range=40,fov=50,rays=5,lastScan=0,interval=0.5,hits={},params=RaycastParams.new()}
Vision.params.FilterType = Enum.RaycastFilterType.Exclude
Vision.params.FilterDescendantsInstances = {LocalPlayer.Character}
function Vision.scan(origin, lookDir)
   if not origin or not lookDir then return {} end
   local results = {}
   local halfFov = math.rad(Vision.fov / 2)
   local step = (halfFov * 2) / (Vision.rays - 1)
   for i = 0, Vision.rays - 1 do
      local angle = -halfFov + (i * step)
      local dir = (lookDir * CFrame.Angles(0, angle, 0)).LookVector
      local ray = workspace:Raycast(origin, dir * Vision.range, Vision.params)
      if ray and ray.Instance then table.insert(results, {instance=ray.Instance, position=ray.Position, distance=ray.Distance}) end
   end
   Vision.hits = results; return results
end
local Scanner = {interactables={},remotes={},prompts={},lastScan=0,interval=8}
function Scanner.scan()
   if tick()-Scanner.lastScan<Scanner.interval then return end
   Scanner.lastScan=tick(); Scanner.interactables={}; Scanner.prompts={}; Scanner.remotes={}
   for _,obj in ipairs(workspace:GetDescendants()) do
      if obj:IsA("ProximityPrompt") then
         local parent=obj.Parent; local pos=parent:IsA("BasePart") and parent.Position or Vector3.new(0,0,0)
         Scanner.prompts[obj]={pos=pos,action=obj.ActionText or "",key=obj.KeyboardKeyCode.Name,hold=obj.HoldDuration,parent=parent,enabled=obj.Enabled}
      end
   end
   for _,obj in ipairs(game:GetService("ReplicatedStorage"):GetDescendants()) do
      if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then Scanner.remotes[obj.Name]=obj end
   end
end
local LogicSim = {learned={},activeHooks={},recordWindow=0.8}
function LogicSim.hookRemotes()
   for name,remote in pairs(Scanner.remotes) do
      if remote:IsA("RemoteEvent") and not LogicSim.activeHooks[name] then
         local orig=remote.FireServer
         remote.FireServer=function(self,...)
            local args={...}; local key=name.."_"..tostring(args[1] or "")
            LogicSim.learned[key]=LogicSim.learned[key] or {type="remote",remote=remote,args=args,confidence=0,lastSeen=tick(),count=0}
            LogicSim.learned[key].count+=1; LogicSim.learned[key].confidence=math.min(100,Quad.reinforce(0,LogicSim.learned[key].count,3))
            LogicSim.learned[key].lastSeen=tick()
            return orig(self,...)
         end
         LogicSim.activeHooks[name]=true
      end
   end
end
function LogicSim.hookPrompts()
   for prompt,data in pairs(Scanner.prompts) do
      if not LogicSim.activeHooks[prompt] then
         LogicSim.activeHooks[prompt]=prompt.Triggered:Connect(function(player)
            if player~=LocalPlayer then return end
            local key="prompt_"..prompt.Parent.Name
            LogicSim.learned[key]=LogicSim.learned[key] or {type="prompt",prompt=prompt,confidence=0,lastSeen=tick(),count=0}
            LogicSim.learned[key].count+=1; LogicSim.learned[key].confidence=math.min(100,Quad.reinforce(0,LogicSim.learned[key].count,4))
            LogicSim.learned[key].lastSeen=tick()
         end)
      end
   end
end
function LogicSim.simulate(triggerKey)
   local entry=LogicSim.learned[triggerKey]
   if not entry or entry.confidence<40 then return false,"Low confidence" end
   if entry.type=="remote" and entry.remote then pcall(function() entry.remote:FireServer(table.unpack(entry.args or {})) end); return true,"Remote fired"
   elseif entry.type=="prompt" and entry.prompt then pcall(function() entry.prompt:Trigger() end); return true,"Prompt triggered" end
   return false,"Failed"
end
function LogicSim.getNearbyTriggers(pos,radius)
   local nearby={}
   for key,data in pairs(LogicSim.learned) do
      local srcPos=nil
      if data.type=="prompt" and data.prompt and data.prompt.Parent:IsA("BasePart") then srcPos=data.prompt.Parent.Position
      elseif data.remote and data.lastPos then srcPos=data.lastPos end
      if srcPos and (srcPos-pos).Magnitude<=radius then table.insert(nearby,{key=key,data=data,dist=(srcPos-pos).Magnitude}) end
   end
   table.sort(nearby,function(a,b) return a.dist<b.dist end); return nearby
end

-- ============================================================
-- SECTION 10: GHOST / LEND CONTROLLER
-- ============================================================
local Ghost={model=nil}
function Ghost.spawn()
   if Ghost.model then pcall(Ghost.model.Destroy,Ghost.model) end
   local c=LocalPlayer.Character; if not c then return end
   local g=c:Clone(); g.Name="AdaptivityAI_Ghost"
   for _,v in ipairs(g:GetDescendants()) do if v:IsA("Script") or v:IsA("LocalScript") then v:Destroy() end end
   for _,p in ipairs(g:GetDescendants()) do if p:IsA("BasePart") then p.Transparency=0.55; p.CanCollide=false; p.Color=Color3.fromRGB(120,170,255); p.Material=Enum.Material.Neon end end
   local hrp,gr=c:FindFirstChild("HumanoidRootPart"),g:FindFirstChild("HumanoidRootPart")
   if hrp and gr then gr.CFrame=hrp.CFrame*CFrame.new(3,0,0) end
   g.Parent=workspace; Ghost.model=g
end
function Ghost.start(m)
   local p=ensurePlace(); if not p or #p.sess==0 then UI.toast("āš ļø Train AI first"); return false end
   table.sort(p.sess,function(a,b) return Confidence.calc(#(a.actions or {}),1)>Confidence.calc(#(b.actions or {}),1) end)
   if Confidence.calc(#(p.sess[1].actions or {}),1)<25 then UI.toast("āš ļø Confidence <25%. Train more."); return false end
   local Replay={sess=p.sess[1],idx=1,speed=1,loop="loop"}
   AI._Replay=Replay; AI.mode=m
   if m=="ghost" then Ghost.spawn(); UI.toast("šŸ‘» Ghost ON") else UI.toast("šŸ¤– Lend ON (F to reclaim)") end
   return true
end
function Ghost.reclaim() AI.mode="idle"; if Ghost.model then pcall(Ghost.model.Destroy,Ghost.model); Ghost.model=nil end; UI.toast("šŸ›‘ Control Reclaimed") end
function Ghost.step()
   local R=AI._Replay; if not R or AI.paused then return end
   local acts=R.sess.actions; if R.idx>#acts then R.idx=(R.loop=="loop" and 1 or #acts+1); if R.idx>#acts and R.loop=="once" then Ghost.reclaim(); return end end
   local a=acts[R.idx]; R.idx+=1
   if a.type=="move" and a.data then
      local t=Vector3.new(a.data.x,a.data.y,a.data.z)
      if AI.mode=="ghost" and Ghost.model then local h=Ghost.model:FindFirstChildOfClass("Humanoid"); if h then h.WalkSpeed=(AI.persona=="Aggressive" and 22 or 16); h:MoveTo(t) end
      else local h=LocalPlayer.Character:FindFirstChildOfClass("Humanoid"); if h then h.WalkSpeed=(AI.persona=="Aggressive" and 22 or 16); h:MoveTo(t) end
   end
end

-- ============================================================
-- SECTION 11: PREDICTION, URGENCY, GOALS, MACROS, ANOMALIES
-- ============================================================
local WM={}, Urgency=0, Goals={current="explore"}, Macros={}, Anomalies={}
function Urgency.update()
   local raw=0; local h=LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
   if h and h.Health<h.MaxHealth*0.4 then raw+=40 end
   for _,p in ipairs(Players:GetPlayers()) do if p~=LocalPlayer and p.Character and p.Character:FindFirstChildOfClass("Humanoid") and p.Character:FindFirstChildOfClass("Humanoid").WalkSpeed>20 then raw+=15 end end
   Urgency=Urgency*0.8+raw*0.2; Urgency=math.min(100,Urgency)
end
function Goals.infer()
   if #WM<4 then return Goals.current end
   local recent={}; for i=math.max(1,#WM-5),#WM do table.insert(recent,WM[i].type or "?") end
   local scores={explore=0,combat=0,interact=0,escape=0,idle=0}
   for _,r in ipairs(recent) do if r=="move" then scores.explore+=1 elseif r=="sprint" then scores.combat+=1 elseif r=="ui_click" then scores.interact+=1 end end
   if Urgency>50 then scores.escape+=2 end
   local best="explore",bs=-1; for g,s in pairs(scores) do if s>bs then best=g;bs=s end end; Goals.current=best; return best
end
function Macros.push(act)
   table.insert(Macros,act); if #Macros>15 then table.remove(Macros,1) end
   if #Macros>=5 then local pl=ensurePlace(); pl.macros=pl.macros or {}; pl.macros[Macros[#Macros]]=(pl.macros[Macros[#Macros]] or 0)+1 end
end
function Anomaly.check(act)
   local pl=ensurePlace(); if not pl or #pl.sess<2 then return end
   for _,s in ipairs(pl.sess) do for _,a in ipairs(s.actions) do if a.type==act then return end end end
   Anomalies[act]=(Anomalies[act] or 0)+1
end

-- ============================================================
-- SECTION 12: UI SYSTEM (LIGHT/DARK)
-- ============================================================
local Theme = {isDark=false,c={bg=Color3.fromRGB(245,247,250),panel=Color3.fromRGB(255,255,255),txt=Color3.fromRGB(30,30,40),dim=Color3.fromRGB(120,125,140),acc=Color3.fromRGB(60,120,255),ok=Color3.fromRGB(40,180,100),warn=Color3.fromRGB(240,180,40),err=Color3.fromRGB(220,60,60),brd=Color3.fromRGB(210,215,225)}}
function Theme.setDark() Theme.isDark=true; Theme.c={bg=Color3.fromRGB(18,20,28),panel=Color3.fromRGB(24,26,36),txt=Color3.fromRGB(225,225,235),dim=Color3.fromRGB(130,135,150),acc=Color3.fromRGB(80,140,255),ok=Color3.fromRGB(50,200,120),warn=Color3.fromRGB(245,195,60),err=Color3.fromRGB(230,75,75),brd=Color3.fromRGB(40,45,60)} end
function Theme.setLight() Theme.isDark=false; Theme.c={bg=Color3.fromRGB(245,247,250),panel=Color3.fromRGB(255,255,255),txt=Color3.fromRGB(30,30,40),dim=Color3.fromRGB(120,125,140),acc=Color3.fromRGB(60,120,255),ok=Color3.fromRGB(40,180,100),warn=Color3.fromRGB(240,180,40),err=Color3.fromRGB(220,60,60),brd=Color3.fromRGB(210,215,225)} end

local UI={open=true,frame=nil,mini=nil,lbls={},bars={}}
local function btn(p,t,sz,pos,col) local b=Instance.new("TextButton"); b.Size=sz; b.Position=pos; b.BackgroundColor3=col or Theme.c.acc; b.TextColor3=Theme.c.txt; b.Text=t; b.Font=Enum.Font.GothamBold; b.TextSize=12; b.BorderSizePixel=0; b.Parent=p; Instance.new("UICorner").Parent=b; return b end
local function lbl(p,t,sz,pos,col,ts) local l=Instance.new("TextLabel"); l.Size=sz; l.Position=pos; l.BackgroundTransparency=1; l.TextColor3=col or Theme.c.txt; l.Text=t; l.Font=Enum.Font.Gotham; l.TextSize=ts or 12; l.Parent=p; return l end
function UI.toast(m) local t=Instance.new("TextLabel"); t.Size=UDim2.new(0,220,0,28); t.Position=UDim2.new(0.5,-110,0,55); t.BackgroundColor3=Theme.c.panel; t.TextColor3=Theme.c.txt; t.Text=m; t.Font=Enum.Font.Gotham; t.TextSize=11; t.ZIndex=90; t.Parent=UI.screen; Instance.new("UICorner").Parent=t; TweenService:Create(t,TweenInfo.new(0.2),{BackgroundTransparency=0}):Play(); task.delay(2,function() TweenService:Create(t,TweenInfo.new(0.3),{BackgroundTransparency=1}):Play(); task.wait(0.3); t:Destroy() end) end
function UI.toggle() if UI.frame then UI.frame.Visible=not UI.frame.Visible; UI.mini.Visible=not UI.frame.Visible end end
function UI.build()
   local sg=Instance.new("ScreenGui"); sg.Name="AdaptivityAIGUI"; sg.ResetOnSpawn=false; sg.Parent=PlayerGui; UI.screen=sg
   UI.mini=btn(sg,"🧠",UDim2.new(0,42,0,42),UDim2.new(0,10,0.4,0),Theme.c.acc); UI.mini.MouseButton1Click:Connect(UI.toggle)
   local f=Instance.new("Frame"); f.Size=UDim2.new(0,460,0,320); f.Position=UDim2.new(0,10,0.1,0); f.BackgroundColor3=Theme.c.bg; f.Parent=sg; UI.frame=f; Instance.new("UICorner").Parent=f
   local tb=Instance.new("Frame"); tb.Size=UDim2.new(1,0,0,30); tb.BackgroundColor3=Theme.c.panel; tb.Parent=f
   lbl(tb,"🧠 AdaptivityAI V1",UDim2.new(0.7,0,1,0),UDim2.new(0,0,0,0),Theme.c.txt,12).Font=Enum.Font.GothamBold
   local cb=btn(tb,"āœ•",UDim2.new(0,26,0,26),UDim2.new(1,-30,0,2),Theme.c.err); cb.MouseButton1Click:Connect(UI.toggle)
   local ds,dp,sp=false,nil,nil; tb.InputBegan:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 then ds=true; dp=i.Position; sp=f.Position end end)
   UserInput.InputChanged:Connect(function(i) if not ds then return end if i.UserInputType==Enum.UserInputType.MouseMovement then local d=i.Position-dp; f.Position=UDim2.new(sp.X.Scale,sp.X.Offset+d.X,sp.Y.Scale,sp.Y.Offset+d.Y) end end)
   UserInput.InputEnded:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 then ds=false end end)
   local rh=btn(f,"",UDim2.new(0,14,0,14),UDim2.new(1,-14,1,-14),Theme.c.acc); local rs,rs2,ss=false,nil,nil
   rh.InputBegan:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 then rs=true; rs2=i.Position; ss=f.AbsoluteSize end end)
   UserInput.InputChanged:Connect(function(i) if not rs then return end if i.UserInputType==Enum.UserInputType.MouseMovement then local d=i.Position-rs2; local w=math.clamp(ss.X+d.X,300,650); local ht=math.clamp(ss.Y+d.Y,200,500); f.Size=UDim2.new(0,w,0,ht) end end)
   UserInput.InputEnded:Connect(function(i) if i.UserInputType==Enum.UserInputType.MouseButton1 then rs=false end end)
   local sc=Instance.new("ScrollingFrame"); sc.Size=UDim2.new(1,0,1,-55); sc.Position=UDim2.new(0,0,0,55); sc.BackgroundTransparency=1; sc.CanvasSize=UDim2.new(0,0,0,480); sc.Parent=f
   local y=8
   UI.lbls.mode=lbl(sc,"🧠 IDLE",UDim2.new(1,-10,0,18),UDim2.new(0,5,0,y),Theme.c.acc,14); y+=20
   UI.lbls.game=lbl(sc,"Game: ...",UDim2.new(1,-10,0,14),UDim2.new(0,5,0,y),Theme.c.dim,10); y+=16
   UI.lbls.sess=lbl(sc,"Sessions: 0",UDim2.new(0.5,-5,0,14),UDim2.new(0,5,0,y),Theme.c.txt,10)
   UI.lbls.act=lbl(sc,"Actions: 0",UDim2.new(0.5,-5,0,14),UDim2.new(0.5,0,0,y),Theme.c.txt,10); y+=16
   lbl(sc,"šŸŖ™ Tokens",UDim2.new(0.45,0,0,12),UDim2.new(0,5,0,y),Theme.c.warn,10)
   UI.lbls.tok=lbl(sc,"0%",UDim2.new(0.15,0,0,12),UDim2.new(0.3,0,0,y),Theme.c.txt,10)
   local _,bf=lbl(sc,"Move",UDim2.new(0.15,0,0,12),UDim2.new(0.5,0,0,y),Theme.c.dim,10); y+=14
   UI.bars.move=lbl(sc,"0%",UDim2.new(0.3,0,0,12),UDim2.new(0.65,0,0,y-1),Theme.c.ok,10); y+=14
   local _,bu=lbl(sc,"UI",UDim2.new(0.15,0,0,12),UDim2.new(0,5,0,y),Theme.c.dim,10)
   UI.bars.ui=lbl(sc,"0%",UDim2.new(0.3,0,0,12),UDim2.new(0.65,0,0,y),Theme.c.acc,10); y+=18
   local b1=btn(sc,"šŸ‘ Observer",UDim2.new(1,-10,0,26),UDim2.new(0,5,0,y),Theme.c.ok)
   local b2=btn(sc,"šŸ‘» Clone",UDim2.new(1,-10,0,26),UDim2.new(0,5,0,y+30))
   local b3=btn(sc,"šŸ¤– Lend",UDim2.new(1,-10,0,26),UDim2.new(0,5,0,y+60),Theme.c.warn)
   local b4=btn(sc,"šŸŒ™ Theme",UDim2.new(1,-10,0,26),UDim2.new(0,5,0,y+90),Theme.c.brd)
   b1.MouseButton1Click:Connect(function() if Observer.active then Observer.stop(); b1.Text="šŸ‘ Observer" else Observer.start(); b1.Text="ā¹ Stop" end UI.up() end)
   b2.MouseButton1Click:Connect(function() if Clone.active then Clone.reclaim(); b2.Text="šŸ‘» Clone" else if Clone.startCurious() then b2.Text="ā¹ Stop" end end UI.up() end)
   b3.MouseButton1Click:Connect(function() if AI.mode=="lend" then Clone.reclaim(); b3.Text="šŸ¤– Lend" else AI.mode="lend"; b3.Text="šŸ›‘ Reclaim"; UI.toast("šŸ¤– Lend ON (F to reclaim)") end UI.up() end)
   b4.MouseButton1Click:Connect(function() if Theme.isDark then Theme.setLight(); b4.Text="šŸŒ™ Theme" else Theme.setDark(); b4.Text="ā˜€ļø Theme" end UI.apply() end)
   UI.apply(); UI.up()
end
function UI.apply()
   if not UI.frame then return end; UI.frame.BackgroundColor3=Theme.c.bg; UI.frame:FindFirstChildWhichIsA("Frame").BackgroundColor3=Theme.c.panel
   for _,c in ipairs(UI.frame:GetDescendants()) do if c:IsA("TextLabel") or c:IsA("TextBox") then c.TextColor3=Theme.c.txt end; if c:IsA("TextButton") and c.TextSize<14 then c.BackgroundColor3=Theme.c.acc; c.TextColor3=Theme.c.txt end end
end
function UI.up()
   local p=ensurePlace(); UI.lbls.mode.Text=(Clone.active and "šŸ‘» CLONE" or AI.mode:upper()).." "..(AI.paused and "āø" or "")
   UI.lbls.game.Text="Game: "..(p.name or "Unknown"); UI.lbls.sess.Text="Sessions: "..#p.sess; UI.lbls.act.Text="Actions: "..(p.totalActions or 0)
   UI.lbls.tok.Text=math.floor((Tokens.cur/Tokens.max)*100).."%"
   if UI.bars.move then UI.bars.move.Text=math.floor(p.conf.move).."%" end; if UI.bars.ui then UI.bars.ui.Text=math.floor(p.conf.ui).."%" end
end

-- ============================================================
-- SECTION 13: INPUT & CHAT COMMANDS
-- ============================================================
if not isMobile then
   UserInput.InputBegan:Connect(function(i,g)
      if g then return end; local k=i.KeyCode.Name
      if k==Brain.cfg.keys.reclaim and (AI.mode=="lend" or Clone.active) then Clone.reclaim()
      elseif k==Brain.cfg.keys.toggle then if Observer.active then Observer.stop() else Observer.start() end
      elseif k==Brain.cfg.keys.ghost then if Clone.active then Clone.reclaim() else Clone.startCurious() end
      elseif k==Brain.cfg.keys.gui then UI.toggle() end
   end)
end
pcall(function() LocalPlayer.Chatted:Connect(function(m) local p=m:lower():split(" "); if p[1]~="/adapt" then return end
   if p[2]=="observe" then Observer.start() elseif p[2]=="stop" then Observer.stop()
   elseif p[2]=="clone" then Clone.startCurious() elseif p[2]=="reclaim" then Clone.reclaim()
   elseif p[2]=="pause" then AI.paused=not AI.paused; UI.toast(AI.paused and "āø Paused" or "ā–¶ Resumed")
   elseif p[2]=="save" then saveBrain(); UI.toast("šŸ’¾ Saved")
   elseif p[2]=="tokens" then UI.toast("šŸŖ™ "..math.floor(Tokens.cur).." / "..Tokens.max)
   elseif p[2]=="scan" then Scanner.scan(); LogicSim.hookRemotes(); LogicSim.hookPrompts(); UI.toast("šŸ” Workspace scanned")
   elseif p[2]=="triggers" then local c=0; for _ in pairs(LogicSim.learned) do c+=1 end; UI.toast("šŸ“¦ Learned triggers: "..c)
   elseif p[2]=="status" then UI.toast("šŸ“Š Mode:"..AI.mode.." Sess:"..#ensurePlace().sess.." Conf:"..math.floor(ensurePlace().conf.move).."%")
   elseif p[2]=="help" then UI.toast("šŸ“– /adapt observe stop clone reclaim pause save tokens scan triggers status help")
   end end) end)

-- ============================================================
-- SECTION 14: CONSOLIDATED HEARTBEAT & MAIN LOOP
-- ============================================================
local lt,ls,tk,vt=0,0,0,0
RunService.Heartbeat:Connect(function(dt)
   tk+=dt; Tokens.regen(dt); Perf.memoryGuard()
   local frameStart=os.clock()
   -- Vision & Scanner
   vt+=dt; if vt>=Vision.interval then vt=0
      local char=LocalPlayer.Character; if char then local hrp=char:FindFirstChild("HumanoidRootPart"); local cam=workspace.CurrentCamera
         if hrp and cam then Vision.scan(hrp.Position+Vector3.new(0,2,0), cam.CFrame.LookVector) end
      end
      Scanner.scan(); LogicSim.hookPrompts()
   end
   -- Observer learning tick
   lt+=dt; if lt>=0.15 and Observer.active then lt=0
      local c=LocalPlayer.Character; if c then local h=c:FindFirstChild("HumanoidRootPart")
         if h and (h.Position-Observer.lastPos).Magnitude>2 then
            Observer.lastPos=h.Position; Observer.rec(h.Position,"move")
            table.insert(WM,{type="move",t=os.time()}); if #WM>15 then table.remove(WM,1) end
            Macros.push("move"); Anomaly.check("move")
         end
      end
   end
   -- Clone curious learning + crowd observe
   if Clone.active then Clone.crowdTick(dt); if Clone.curious then Clone.stepCurious(dt) end end
   -- Ghost/Lend step
   if AI.mode=="ghost" or AI.mode=="lend" then Ghost.step() end
   -- Urgency & Goals
   if tk%1<dt then Urgency.update(); Goals.infer() end
   -- Auto-save
   ls+=dt; if ls>=40 then ls=0; saveBrain(); UI.up() end
   -- Budget yield
   if not Perf.budgetCheck(frameStart) then coroutine.yield() end
end)

-- ============================================================
-- SECTION 15: INITIALIZATION & SCRIPTBLOX FOOTER
-- ============================================================
local function init()
   loadBrain(); Perf.profileTier()
   if Brain.cfg.theme=="dark" then Theme.setDark() else Theme.setLight() end
   Tokens.max=Brain.cfg.tokens or 500; UI.build(); UI.up()
   task.wait(0.5); UI.toast("AdaptivityAI V1 Loaded | Tier "..Perf.tier.." | šŸŖ™ "..math.floor(Tokens.cur).."/"..Tokens.max)
   print("[AdaptivityAI] Ready. Use /adapt help or GUI buttons.")
   print("[AdaptivityAI] ScriptBlox V1 Release | Optimized | Quadratic Learning | Safe")
end; init()

--[[
šŸ“¦ SCRIPTBLOX RELEASE NOTES:
- Fully client-side, executor-safe, zero server dependencies
- Pseudo-Quadratic Learning Engine for pattern reinforcement, spatial decay, and confidence scaling
- 10-Layer Performance Stack with ~2ms/frame budget cap
- Light/Dark UI, draggable/resizable, live stats, token/confidence bars
- Observer Mode + Clone-Only Crowd Observe + Ghost/Lend replay
- Vision raycasting, workspace scanner, logic simulator for prompts/remotes
- Chat commands: /adapt help | Keybinds: G=Observe H=Ghost J=GUI F=Reclaim
- Saves to AdaptivityAI/brain_<PlaceId>.json via writefile/readfile
- No malicious code, no account automation, Roblox ToS compliant
- Credit: AdaptivityAI Team | Version 1.0.0
]]

Features & Information

Adaptivity AI is a self learning ai With a lotta features to train your ai. Have fun training ai

Community Comments (1)

ggggGTIffggggGTIffMay 28, 2026

Is there a problem

More Scripts for Universal Scripts