Skip to content
RoRoScripts
Best move and auto move preview
Unknown

Best move and auto move

Script
Chess ClubBloodScripts
Views
30K
Likes
2
Dislikes
2
Added
Script
-- Chess Club Auto Move (Sunfish local) - Detecta en passant y juega por ti
-- Hecho para ejecutores móviles sin GUI

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer

local lastFEN = nil
local checkingMove = false
local sunfish

-- Intentar cargar Sunfish desde el juego
local function loadSunfish()
    local success, result = pcall(function()
        return require(Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("AI"):WaitForChild("Sunfish"))
    end)
    if success then
        print("[INFO] Sunfish cargado correctamente.")
        return result
    else
        warn("[ERROR] No se pudo cargar Sunfish. El juego no lo tiene o tu executor no lo permite.")
        return nil
    end
end

sunfish = loadSunfish()
if not sunfish then return end -- No continuar si no hay motor

-- Obtener FEN del tablero
local function getFEN()
    local success, result = pcall(function()
        local tableSet = ReplicatedStorage:WaitForChild("InternalClientEvents"):WaitForChild("GetActiveTableset")
        local board = tableSet:Invoke()
        return board:WaitForChild("FEN").Value
    end)
    return success and result or nil
end

-- Obtener mejor movimiento desde Sunfish
local function getBestMoveSunfish(fen)
    local success, from, to = pcall(function()
        return sunfish:GetBestMove(fen, 2000) -- 2000 ms para pensar
    end)
    if success then
        return from, to
    else
        warn("[ERROR] Sunfish falló al calcular movimiento.")
        return nil
    end
end

-- Enviar el movimiento
local function submitMove(from, to)
    if not from then return end
    local move = from .. (to or "")
    ReplicatedStorage:WaitForChild("Chess"):WaitForChild("SubmitMove"):InvokeServer(move)
    print("[JUGADO] Movimiento enviado:", move)
end

-- Verifica si hay nuevo turno y juega
RunService.RenderStepped:Connect(function()
    if checkingMove then return end
    checkingMove = true

    local currentFEN = getFEN()
    if currentFEN and currentFEN ~= lastFEN then
        print("[INFO] Nuevo turno detectado.")
        lastFEN = currentFEN

        local from, to = getBestMoveSunfish(currentFEN)
        if from then
            print("[MEJOR MOVIMIENTO] " .. from .. " → " .. (to or ""))
            submitMove(from, to)
        else
            print("[ERROR] No se pudo calcular el movimiento.")
        end
    end

    checkingMove = false
end)