-- [[ Rscripts Risk Notice ]] -- This script is not verified by rscripts.net. Deal with caution. -- -- Stay safe: -- • Never log in on unofficial Roblox sites or lookalike domains. -- • Real Roblox links use roblox.com (check the .com ending). -- • Treat fake Roblox login / "claim reward" pages as phishing. -- [[ End Rscripts Risk Notice ]] local Players = game:GetService("Players") local RS = game:GetService("ReplicatedStorage") local ENV = (getgenv and getgenv()) or _G local CFG = { QUICK = 0.15, ROUNDS = { { 99, 0.015 }, { 8, 0.1 }, { 3, 0.6 } }, DEPTH = 14, NEAR = 60, GREAT_GAP = 150, BRILLIANT_GAP = 30, WINNING = 400, LOSING = -150, SAC = 2, PONDER = true, } local VAL = { [0] = 0, 1, 3, 3, 5, 9, 0 } local PROMO, NONE = { 5, 4, 3, 2 }, { false } local PROMO_LETTER = { [4] = "R", [3] = "B", [2] = "N" } local STALE = {} local COLORS = { best = { Color3.fromRGB(150, 188, 75), "1" }, great = { Color3.fromRGB(92, 139, 176), "!" }, brilliant = { Color3.fromRGB(27, 172, 166), "!!" }, } if ENV.__ChessHelperStop then pcall(ENV.__ChessHelperStop) end local lp = Players.LocalPlayer local alive, layer, folder = true, nil, nil ENV.__ChessHelperStop = function() alive = false if layer then layer:Destroy() end if folder then folder:Destroy() end end local function make(class, props, parent) local o = Instance.new(class) for k, v in pairs(props) do o[k] = v end o.Parent = parent return o end local function labelOf(a) if a.mate then return "M" .. a.mate end return COLORS[a.kind][2] .. (PROMO_LETTER[a.p] and ("=" .. PROMO_LETTER[a.p]) or "") end local function getLayer() if layer and layer.Parent then return layer end local b = lp.PlayerGui:FindFirstChild("Board2D") local sq = b and b:FindFirstChild("Squares", true) if not sq then return end layer = make("Frame", { BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), ZIndex = 9 }, sq) return layer end local function point(i, flip) local x, y = (i - 1) % 8, (i - 1) // 8 if flip then x = 7 - x else y = 7 - y end return Vector2.new((x + 0.5) / 8, (y + 0.5) / 8) end local function draw2(list, flip) local l = getLayer() if not l then return end l:ClearAllChildren() for _, a in ipairs(list or {}) do local c = COLORS[a.kind] local p0, p1 = point(a.f, flip), point(a.t, flip) local d = p1 - p0 local body = math.max(0, d.Magnitude - 0.045) local mid = p0 + d.Unit * (body / 2) local tip = p0 + d.Unit * (d.Magnitude - 0.025) local rot = math.deg(math.atan2(d.Y, d.X)) local shaft = make("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(mid.X, mid.Y), Size = UDim2.new(body, 0, 0.024, 0), Rotation = rot, BackgroundColor3 = c[1], BackgroundTransparency = 0.25, BorderSizePixel = 0, ZIndex = 9, }, l) make("UICorner", { CornerRadius = UDim.new(1, 0) }, shaft) make("TextLabel", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(tip.X, tip.Y), Size = UDim2.fromScale(0.075, 0.075), Rotation = rot + 90, BackgroundTransparency = 1, TextScaled = true, Text = utf8.char(9650), TextColor3 = c[1], TextTransparency = 0.25, ZIndex = 9, }, l) local badge = make("TextLabel", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(p1.X + 0.05, p1.Y - 0.05), Size = UDim2.fromScale(0.07, 0.07), BackgroundColor3 = c[1], BorderSizePixel = 0, TextScaled = true, Font = Enum.Font.GothamBold, Text = labelOf(a), TextColor3 = Color3.new(1, 1, 1), ZIndex = 10, }, l) make("UICorner", { CornerRadius = UDim.new(1, 0) }, badge) end end local function tableInfo(id) local root = workspace:FindFirstChild("ChessTables") if not root then return end for _, m in ipairs(root:GetChildren()) do if m:GetAttribute("TableId") == id then local board = m:FindFirstChild("Board") if not board then return end local surface = board.Size.Y / 2 + 0.02 local sqs = m:FindFirstChild("Squares") local p = sqs and sqs:FindFirstChildWhichIsA("BasePart") if p then surface = board.CFrame:PointToObjectSpace(p.Position + p.CFrame.UpVector * p.Size.Y / 2).Y + 0.002 end return board, m:GetAttribute("SquareSize") or 0.375, surface end end end local function draw3(list, s) if not (folder and folder.Parent) then if not list then return end folder = make("Folder", { Name = "ChessHelper" }, workspace) end folder:ClearAllChildren() if not (list and s) then return end local board, sq, surface = tableInfo(s.id) if not board then return end local up = board.CFrame.UpVector local function at(i) return (board.CFrame * CFrame.new(((i - 1) % 8 + 1 - 4.5) * sq, surface, -((i - 1) // 8 + 1 - 4.5) * sq)).Position + up * 0.02 end for _, a in ipairs(list) do local c = COLORS[a.kind] local p0, p1 = at(a.f), at(a.t) local dir = (p1 - p0).Unit local side = dir:Cross(up).Unit local hl, hw = sq * 0.42, sq * 0.5 local body = math.max(0.01, (p1 - p0).Magnitude - hl - sq * 0.12) local start = p0 + dir * (sq * 0.12) local model = make("Model", {}, folder) make("Highlight", { FillColor = c[1], FillTransparency = 0.15, OutlineTransparency = 1, DepthMode = Enum.HighlightDepthMode.AlwaysOnTop, Adornee = model, }, model) local function part(class, size, cf) return make(class, { Anchored = true, CanCollide = false, CanQuery = false, CanTouch = false, CastShadow = false, Material = Enum.Material.SmoothPlastic, Color = c[1], Size = size, CFrame = cf, }, model) end local shaft = part("Part", Vector3.new(sq * 0.17, 0.008, body), CFrame.lookAt(start + dir * (body / 2), start + dir * body, up)) local headC = start + dir * body + dir * (hl / 2) part("WedgePart", Vector3.new(0.008, hw / 2, hl), CFrame.fromMatrix(headC - side * (hw / 4), up, -side, -dir)) part("WedgePart", Vector3.new(0.008, hw / 2, hl), CFrame.fromMatrix(headC + side * (hw / 4), -up, side, -dir)) local tag = make("BillboardGui", { Size = UDim2.fromOffset(30, 26), AlwaysOnTop = true, Adornee = shaft, StudsOffsetWorldSpace = Vector3.new(0, 0.3, 0), }, shaft) local text = make("TextLabel", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = c[1], TextColor3 = Color3.new(1, 1, 1), Font = Enum.Font.GothamBold, TextSize = 15, Text = labelOf(a), }, tag) make("UICorner", { CornerRadius = UDim.new(1, 0) }, text) end end local function draw(list, s) if not alive then return end local b = lp.PlayerGui:FindFirstChild("Board2D") local two = b and b.Enabled draw2(two and list or nil, s and s.color == -1) draw3(not two and list or nil, s) end local function findModule(name) for _, root in ipairs({ RS, game }) do for _, d in ipairs(root:GetDescendants()) do if d.Name == name and d:IsA("ModuleScript") then return d end end end end local function inferCastle(b) local c = 0 if b[5] == 6 then if b[8] == 4 then c = c + 1 end if b[1] == 4 then c = c + 2 end end if b[61] == -6 then if b[64] == -4 then c = c + 4 end if b[57] == -4 then c = c + 8 end end return c end local function inferEP(s) local l = s.last if l and l.from and l.to and math.abs(l.to - l.from) == 16 and math.abs(s.board[l.to] or 0) == 1 then return (l.from + l.to) // 2 end end local function after(b, f, t, promo) local n = table.clone(b) local p = n[f] local sign = p > 0 and 1 or -1 local kind = math.abs(p) if kind == 6 and math.abs(t - f) == 2 then local rf, rt = t > f and f + 3 or f - 4, t > f and f + 1 or f - 1 n[rt], n[rf] = n[rf], 0 elseif kind == 1 and (t - f) % 8 ~= 0 and (n[t] or 0) == 0 then n[t - 8 * sign] = 0 end n[t], n[f] = p, 0 if kind == 1 and (t > 56 or t < 9) then n[t] = (promo or 5) * sign end return n end local function sameBoard(a, b) for i = 1, 64 do if (a[i] or 0) ~= (b[i] or 0) then return false end end return true end task.spawn(function() local mod = findModule("ReviewEngine") if not mod then return warn("ChessHelper: ReviewEngine not found") end local ok, RE = pcall(require, mod) if not ok then return warn("ChessHelper: ReviewEngine failed to load") end local bm = findModule("OpeningBook") local okb, book = pcall(function() return bm and require(bm) end) if not okb then book = nil end local api = lp:WaitForChild("PlayerGui"):WaitForChild("Board2DApi", 60) if not api then return warn("ChessHelper: Board2DApi not found") end local cur, nps = nil, 30000 local lastYield = os.clock() local function slice() if os.clock() - lastYield > 0.03 then task.wait() lastYield = os.clock() local c = api:Invoke("state") if not (c and c.id == cur.id and (c.ply or 0) == (cur.ply or 0)) then error(STALE) end end end local function show(list) local c = api:Invoke("state") if c and c.id == cur.id and (c.ply or 0) == (cur.ply or 0) then draw(list, cur) end end local function legal(from, to) local list = api:Invoke("targets", from) if type(list) == "table" then for _, sq in ipairs(list) do if sq == to then return true end end end return false end local function think(sec) local t0 = os.clock() local raw, sc, _, nodes = RE.search(math.max(300, sec * nps / 2), CFG.DEPTH, nil, slice) local dt = os.clock() - t0 if dt > 0.05 and nodes and nodes > 0 then nps = nps * 0.6 + nodes / dt * 0.4 end return raw, sc end local function score(m, sec) RE.play(m) local _, sc = think(sec) RE.takeBack(m) return -sc end local function sacrifice(s, c) local pv = VAL[math.abs(s.board[c.f])] if pv < 3 then return false end local gain = VAL[math.abs(s.board[c.t] or 0)] local loss = 0 RE.play(c.m) for o = 1, 64 do if (s.board[o] or 0) * s.turn < 0 then local r = RE.find(o, c.t) if r then RE.play(r) local back = 0 for q = 1, 64 do if (s.board[q] or 0) * s.turn > 0 and RE.find(q, c.t) then back = VAL[math.abs(s.board[o])] break end end RE.takeBack(r) loss = math.max(loss, pv - back) end end end RE.takeBack(c.m) return loss - gain >= CFG.SAC end local function classify(s, list) local out, top = {}, list[1] for i = 1, math.min(3, #list) do local c = list[i] if top.s - c.s <= CFG.NEAR then local kind = "best" if c.s >= CFG.LOSING and top.s <= CFG.WINNING and top.s - c.s <= CFG.BRILLIANT_GAP and sacrifice(s, c) then kind = "brilliant" elseif i == 1 and list[2] and top.s - list[2].s >= CFG.GREAT_GAP then kind = "great" end out[#out + 1] = { f = c.f, t = c.t, p = c.p, kind = kind, mate = c.s > 29800 and math.ceil((30001 - c.s) / 2) or nil, } end end return out end local function byScore(a, b) if a.r ~= b.r then return a.r > b.r end return a.s > b.s end local function analyse(tgt, emit, real) RE.setBoard(tgt.board, tgt.turn, inferCastle(tgt.board), inferEP(tgt)) lastYield = os.clock() local filter = real and tgt.turn == tgt.color local list = {} for from = 1, 64 do local pc = tgt.board[from] or 0 if pc * tgt.turn > 0 then for to = 1, 64 do for _, p in ipairs(math.abs(pc) == 1 and (to > 56 or to < 9) and PROMO or NONE) do local m = RE.find(from, to, p) if m and (not filter or legal(from, to)) then list[#list + 1] = { m = m, f = from, t = to, p = p or nil, r = 0, s = -1e9 } end end end end end if #list == 0 then return end if book and (tgt.ply or 0) < 26 then local picks = {} for _, c in ipairs(list) do if book.has(after(tgt.board, c.f, c.t, c.p), -tgt.turn) then picks[#picks + 1] = c end end if #picks > 0 then if #picks > 3 then for _, c in ipairs(picks) do c.s = score(c.m, CFG.ROUNDS[1][2]) end table.sort(picks, function(a, b) return a.s > b.s end) end local out = {} for i = 1, math.min(3, #picks) do out[i] = { f = picks[i].f, t = picks[i].t, p = picks[i].p, kind = "best" } end emit(out) return out end end local raw = think(CFG.QUICK) if raw and raw ~= 0 then local f, t, p = RE.squares(raw) for _, c in ipairs(list) do if c.f == f and c.t == t and c.p == p then emit({ { f = f, t = t, p = p, kind = "best" } }) break end end end local out for r, rd in ipairs(CFG.ROUNDS) do for i = 1, math.min(rd[1], #list) do list[i].s = score(list[i].m, rd[2]) list[i].r = r end table.sort(list, byScore) out = classify(tgt, list) emit(out) end return out end RE.newGame() local key, lastPly, ponder while alive do local good, err = pcall(function() local s = api:Invoke("state") if not (s and s.board and s.status == "playing") then key = nil return draw(nil, nil) end local ply = s.ply or 0 if lastPly and ply < lastPly then RE.newGame() end lastPly = ply local k = s.id .. ":" .. ply if k == key then return end draw(nil, s) cur = s local pc = ponder ponder = nil if pc and pc.done and pc.turn == s.turn and sameBoard(pc.board, s.board) then local hit = {} for _, a in ipairs(pc.out) do if legal(a.f, a.t) then hit[#hit + 1] = a end end if #hit > 0 then show(hit) key = k return end end local done, res = pcall(analyse, s, show, true) if not done and res ~= STALE then warn("ChessHelper: " .. tostring(res)) end if done or res ~= STALE then key = k end if done and CFG.PONDER and s.turn ~= s.color and res and res[1] then local a = res[1] local guess = { board = after(s.board, a.f, a.t, a.p), turn = -s.turn } ponder = guess local ok2, e2 = pcall(analyse, { board = guess.board, turn = guess.turn, color = s.color, ply = ply + 1, last = { from = a.f, to = a.t }, }, function(l) guess.out = l end, false) if ok2 then guess.done = true elseif e2 ~= STALE then warn("ChessHelper: " .. tostring(e2)) end end end) if not good then warn("ChessHelper: " .. tostring(err)) end task.wait(0.15) end end)