Run it
Copy the script and paste it into your executor.
.(()
W=:()
CG=:()
UIS=:()
setcl=setclipboard toclipboard
pFolder=W:()
bFolder=W:()
acts={}
turn=
history={}
mCount=
pState={}
PT={Pawn=,Knight=,Bishop=,Rook=,Queen=,King=}
VAL={[]=,[]=,[]=,[]=,[]=,[]=}
MODES = {
{ name = , time = , color = .(, , ) },
{ name = , time = , color = .(, , ) },
{ name = , time = , color = .(, , ) },
{ name = , time = ,color = .(, , ) },
{ name = , time = , color = .(, , ) },
}
modeIdx =
MODE = MODES[modeIdx].name
TIME_BUDGET = MODES[modeIdx].time
botSignSearch =
bit32 = bit32 bit
bxor, band, bor = bit32.bxor, bit32.band, bit32.bor
lshift, rshift = bit32.lshift, bit32.rshift
SQ_X, SQ_Y = {}, {}
i=, SQ_X[i] = (i-)%+; SQ_Y[i] = .((i-)/)+
zobrist = {}
i=,* zobrist[i] = .(, )
zobristSide = .(, )
(pc) pc > pc -pc +
(i, p) (i-)* + p
(g, side)
h =
i=,
pc = g[i]
pc ~= h = (h, zobrist[(i, (pc))])
side == - h = (h, zobristSide)
h
cellPos, cellParts = {}, {}
boardReady =
colorCache = ({}, {__mode=})
(h) (() h:() )
()
boardReady
okAll =
x=, y=,
s = bFolder:(x....y)
s
ok, pos = (() s:().Position )
ok pos
_,c (s:())
c:() pos = c.Position
pos
idx = (y-)*+x
cellPos[idx] = .(pos.X,,pos.Z)
cellParts[idx] = s
okAll =
okAll =
boardReady = okAll
()
_,h (acts) h (h)
acts={}
(obj)
obj
obj:() obj:() obj
obj:(, ) obj:(, )
(obj)
obj ,
obj:() obj.CFrame, obj.Size
obj:()
ok, cf, size = (() obj:() )
ok cf size size.X > size.Z > cf, size
_, c (obj:())
c:() c.Size.X > c.Size.Z > c.CFrame, c.Size
ok, piv = (() obj:() )
ok piv piv, .(, , )
,
(cf, size, col)
sx = (size size.X)
sz = (size size.Z)
sy = (size size.Y)
d = .(sx, sz) *
d < d =
p = .()
p.Name =
p.Size = .(d, , d)
p.CFrame = cf * .(, sy/ + , )
p.Color = col
p.Material = .Material.Neon
p.Anchored =
p.CanCollide = ; p.CanQuery = ; p.CanTouch = ; p.CastShadow =
p.Transparency =
p.Parent = W
.(acts, p)
(adornee, col, fillTransp)
adornee
h = .()
h.FillColor = col; h.OutlineColor = col
h.FillTransparency = fillTransp
h.OutlineTransparency =
h.DepthMode = .HighlightDepthMode.AlwaysOnTop
h.Adornee = adornee; h.Parent = adornee
.(acts, h)
(idx)
idx
cached = cellParts[idx]
cached cached.Parent cached
x = (idx-)% +
y = .((idx-)/) +
byName = bFolder:(x....y)
byName cellParts[idx] = byName byName
cellPos[idx]
best, bestDist = , .huge
_, c (bFolder:())
cf = (c)
cf
flat = .(cf.Position.X, , cf.Position.Z)
d = (flat - cellPos[idx]).Magnitude
d < bestDist bestDist = d; best = c
best bestDist < cellParts[idx] = best best
(obj, col, idx)
obj idx obj = (idx)
obj
adornee = (obj)
adornee (adornee, col, )
cf, size = (obj)
cf (cf, size .(,,), col);
idx cellPos[idx]
(.(cellPos[idx]), .(, , ), col)
(obj, col)
obj
adornee = (obj)
adornee (adornee, col, );
(p)
count =
maxVol =
mainPart =
_, c (p:())
(c:() c:()) c.Transparency <
count = count +
vol = c.Size.X * c.Size.Y * c.Size.Z
vol > maxVol maxVol = vol; mainPart = c
mainPart ,
color = mainPart.Color
partColor
color.R > color.G > color.B > partColor =
color.R < color.G < color.B < partColor = -
b = (color.R + color.G + color.B) /
partColor = (b > ) -
partColor, count
(p)
cached = colorCache[p]
cached cached.partColor
partColor, count = (p)
partColor
colorCache[p] = { partColor = partColor, count = count }
partColor
()
()
g={} i=, g[i]=
models={}
kings = {}
_,p (pFolder:())
p:() PT[p.Name]
pPos=p:().Position
pFlat=.(pPos.X,,pPos.Z)
bIdx,bDist=,.huge
i=,
cellPos[i]
dist=(cellPos[i]-pFlat).Magnitude
dist<bDist bDist=dist bIdx=i
bIdx bDist<
c = (p)
pt = PT[p.Name]
c g[bIdx]=pt*c; models[bIdx]=p
pt == c .(kings, {model=p, idx=bIdx, color=c})
g, models, kings
(g, models, kings)
#kings < ,
botSign = (turn==) -
botKing, enemyKing, rest = , , {}
_,k (kings)
botKing k.color == botSign botKing = k
.(rest, k)
botKing #rest > botKing = rest[]; .(rest, )
#rest > enemyKing = rest[]
botKing g[botKing.idx] = * botSign; models[botKing.idx] = botKing.model
enemyKing g[enemyKing.idx] = - * botSign; models[enemyKing.idx] = enemyKing.model
botKing ~= , enemyKing ~=
PST_RAW = {
[] = {
, , , , , , , ,
, , ,-,-, , , ,
, -,-, , ,-, -, ,
, , , , , , , ,
, , , , , , , ,
, , , , , , , ,
, , , , , , , ,
, , , , , , , ,
},
[] = {
-,-,-,-,-,-,-,-,
-,-, , , , ,-,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-,-, , , , ,-,-,
-,-,-,-,-,-,-,-,
},
[] = {
-,-,-,-,-,-,-,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , ,-,
-,-,-,-,-,-,-,-,
},
[] = {
, , , , , , , ,
, , , , , , , ,
-, , , , , , , -,
-, , , , , , , -,
-, , , , , , , -,
-, , , , , , , -,
-, , , , , , , -,
, , , , , , , ,
},
[] = {
-,-,-, -, -,-,-,-,
-, , , , , , ,-,
-, , , , , , ,-,
-, , , , , , , -,
, , , , , , , -,
-, , , , , , ,-,
-, , , , , , ,-,
-,-,-, -, -,-,-,-,
},
[] = {
-,-,-,-,-,-,-,-,
-,-,-,-,-,-,-,-,
-,-,-,-,-,-,-,-,
-,-,-,-,-,-,-,-,
-,-,-,-,-,-,-,-,
-,-,-,-,-,-,-,-,
, , , , , , , ,
, , , , , , , ,
},
}
PST = {}
pt=,
PST[pt] = {[]={},[-]={}}
cSign ({[]=, [-]=})
i=,
cSign ==
PST[pt][][i] = PST_RAW[pt][i]
x = (i-)%
y = .((i-)/)
mi = (-y)* + x +
PST[pt][-][i] = PST_RAW[pt][mi]
(g, side)
matPST =
wB, bB = ,
wP, bP = {}, {}
wpFiles = {,,,,,,,}
bpFiles = {,,,,,,,}
wPieces =
bPieces =
wK, bK = -, -
matMult = (MODE == )
i=,
pc = g[i]
pc ~=
wPieces = wPieces + (pc > )
bPieces = bPieces + (pc < )
pt = pc > pc -pc
cSign = pc > -
val = VAL[pt] * (pt == matMult) + PST[pt][cSign][i]
pc > matPST = matPST + val matPST = matPST - val
pt ==
x = SQ_X[i]
pc > wpFiles[x] = wpFiles[x]+; wP[#wP+] = {x=x, y=SQ_Y[i], i=i}
bpFiles[x] = bpFiles[x]+; bP[#bP+] = {x=x, y=SQ_Y[i], i=i}
pt ==
pc > wB = wB + bB = bB +
pt ==
pc > wK = i bK = i
wPieces <= bPieces <=
wB == bB ==
wN, bN = ,
i=,
g[i] == wN = wN + g[i] == - bN = bN +
wN + wB + bN + bB <=
score = matPST
wB >= score = score +
bB >= score = score -
x=,
wc, bc = wpFiles[x], bpFiles[x]
wc > score = score - (wc-) *
bc > score = score + (bc-) *
wl = (x == ) wpFiles[x-]
wr = (x == ) wpFiles[x+]
bl = (x == ) bpFiles[x-]
br = (x == ) bpFiles[x+]
wc > wl == wr == score = score - * wc
bc > bl == br == score = score + * bc
_, p (wP)
isPassed =
_, op (bP)
.(op.x - p.x) <= op.y > p.y isPassed = ;
isPassed score = score + (p.y - ) *
_, p (bP)
isPassed =
_, wp (wP)
.(wp.x - p.x) <= wp.y < p.y isPassed = ;
isPassed score = score - ( - p.y) *
wK ~= -
x, y = SQ_X[wK], SQ_Y[wK]
shield =
y >=
dx=-,
x+dx >= x+dx <=
idx = (y-)* + x+dx
g[idx] == shield = shield +
score = score + shield
bK ~= -
x, y = SQ_X[bK], SQ_Y[bK]
shield =
y <=
dx=-,
x+dx >= x+dx <=
idx = y* + x+dx
g[idx] == - shield = shield +
score = score - shield
MODE ==
eK
side > eK = bK eK = wK
eK ~= -
ex, ey = SQ_X[eK], SQ_Y[eK]
attackBonus =
i=,
pc = g[i]
pc * side > .(pc) ~= .(pc) ~=
dx = .(SQ_X[i] - ex)
dy = .(SQ_Y[i] - ey)
dist = .(dx, dy)
dist <= attackBonus = attackBonus + ( - dist) *
score = score + attackBonus
MODE ==
wK ~= -
wk_y = SQ_Y[wK]
wk_y > score = score -
bK ~= -
bk_y = SQ_Y[bK]
bk_y < score = score +
score * side
(g,opp,tx,ty)
py=(opp==) ty- ty+
tx> py>= py<= g[(py-)*+tx-]==*opp
tx< py>= py<= g[(py-)*+tx+]==*opp
_,d ({{,},{,-},{-,},{-,-},{,},{,-},{-,},{-,-}})
nx,ny=tx+d[],ty+d[]
nx>= nx<= ny>= ny<= g[(ny-)*+nx]==*opp
_,d ({{,},{-,},{,},{,-},{,},{,-},{-,},{-,-}})
nx,ny=tx+d[],ty+d[]
nx>= nx<= ny>= ny<= g[(ny-)*+nx]==*opp
_,d ({{,},{-,},{,},{,-}})
cx,cy=tx+d[],ty+d[]
cx>= cx<= cy>= cy<=
pc=g[(cy-)*+cx]
pc~= pc==*opp pc==*opp
cx,cy=cx+d[],cy+d[]
_,d ({{,},{,-},{-,},{-,-}})
cx,cy=tx+d[],ty+d[]
cx>= cx<= cy>= cy<=
pc=g[(cy-)*+cx]
pc~= pc==*opp pc==*opp
cx,cy=cx+d[],cy+d[]
(g,color)
i=,
g[i]==*color (g,-color,SQ_X[i],SQ_Y[i])
(from, to, score)
score < score =
((from-, (to-, )), (score, ))
(mv) (mv, ) +
(mv) ((mv, ), ) +
(mv) (mv, )
TT_MOVE_SCORE =
CAPTURE_BASE =
KILLER_BASE =
HIST_CAP =
killers = {}
histTable = {}
p=, histTable[p] = {} t=, histTable[p][t] =
(g, side, onlyCaps, ttMove, ply)
m = {}
ttCore = ttMove (ttMove)
k1, k2 = ,
ply
k = killers[ply]
k k1 = k[] ; k2 = k[]
(from, to)
core = (from-, (to-, ))
ttCore ~= core == ttCore TT_MOVE_SCORE
victim = g[to]
victim ~=
attacker = .(g[from])
av = VAL[attacker]; av > av =
CAPTURE_BASE + VAL[.(victim)] - av
core == k1 KILLER_BASE +
core == k2 KILLER_BASE +
attacker = .(g[from])
hv = histTable[attacker][to]
hv > HIST_CAP hv = HIST_CAP
hv
(from, to, bonus)
m[#m+] = (from, to, (from, to) + (bonus ))
i=,
pc=g[i]
pc*side>
pt=.(pc)
x=SQ_X[i]; y=SQ_Y[i]
pt==
ny=y+side
ny>= ny<=
ni=(ny-)*+x
onlyCaps g[ni]==
bScore = (mCount<= (x== x==) .(y-ny)==)
(i, ni, bScore)
(side== y==) (side==- y==)
ni2=(y+*side-)*+x
g[ni2]== (i, ni2, bScore)
x> cap=(ny-)*+x- g[cap]*side< (i, cap)
x< cap=(ny-)*+x+ g[cap]*side< (i, cap)
pt==
_,d ({{,},{,-},{-,},{-,-},{,},{,-},{-,},{-,-}})
nx,ny=x+d[],y+d[]
nx>= nx<= ny>= ny<=
ni=(ny-)*+nx tgt=g[ni]
tgt*side<= ( onlyCaps tgt~=) (i, ni)
pt==
_,d ({{,},{-,},{,},{,-},{,},{,-},{-,},{-,-}})
nx,ny=x+d[],y+d[]
nx>= nx<= ny>= ny<=
ni=(ny-)*+nx tgt=g[ni]
tgt*side<= ( onlyCaps tgt~=) (i, ni)
dirs={}
pt== pt== _,d ({{,},{-,},{,},{,-}}) .(dirs,d)
pt== pt== _,d ({{,},{,-},{-,},{-,-}}) .(dirs,d)
_,d (dirs)
cx,cy=x+d[],y+d[]
cx>= cx<= cy>= cy<=
ni=(cy-)*+cx tgt=g[ni]
tgt==
onlyCaps (i, ni)
tgt*side<
(i, ni)
cx,cy=cx+d[],cy+d[]
.(m,(a,b) a>b )
m
(g, mv, hash)
from = (mv, ) +
to = ((mv, ), ) +
movingPiece = g[from]
cap = g[to]
hash = (hash, zobrist[(from, (movingPiece))])
cap ~= hash = (hash, zobrist[(to, (cap))])
hash = (hash, zobrist[(to, (movingPiece))])
hash = (hash, zobristSide)
g[to] = movingPiece; g[from] =
cap, hash
(g, mv, cap)
from = (mv, ) +
to = ((mv, ), ) +
g[from] = g[to]; g[to] = cap
TT = {}
FLAG_EXACT, FLAG_LOWER, FLAG_UPPER = , ,
(hash, entry)
old = TT[hash]
old old.depth > entry.depth
TT[hash] = entry
startTime =
nodeCount =
stopSearch =
gameHashes = {}
(g, alpha, beta, color, hash, qDepth)
stopSearch qDepth > (g, color)
nodeCount = nodeCount +
nodeCount % == .()
nodeCount % == .() - startTime > TIME_BUDGET
stopSearch = ; (g, color)
standPat = (g, color)
standPat >= beta beta
alpha < standPat alpha = standPat
m = (g, color, , , )
_,mv (m)
stopSearch
victimVal = VAL[.(g[(mv)])]
standPat + victimVal + >= alpha
cap, newHash = (g, mv, hash)
(g,color)
score = -(g, -beta, -alpha, -color, newHash, qDepth + )
(g,mv,cap)
score >= beta beta
score > alpha alpha = score
(g,mv,cap)
alpha
(g, depth, alpha, beta, color, hash, ply)
stopSearch (g, color),
nodeCount = nodeCount +
nodeCount % == .()
nodeCount % == .() - startTime > TIME_BUDGET
stopSearch = ; (g,color),
gameHashes[hash] gameHashes[hash] >= ,
origAlpha = alpha
ttEntry = TT[hash]
ttMove =
ttEntry
ttMove = ttEntry.move
ttEntry.depth >= depth
sc = ttEntry.score
ttEntry.flag == FLAG_EXACT sc, ttMove
ttEntry.flag == FLAG_LOWER sc >= beta sc, ttMove
ttEntry.flag == FLAG_UPPER sc <= alpha sc, ttMove
depth <= (g, alpha, beta, color, hash, ),
inCheck = (g, color)
inCheck depth = depth +
depth >= ply > inCheck
hasMaterial =
i=,
pc = g[i]
pc*color >
pt = .(pc)
pt ~= pt ~= hasMaterial =
hasMaterial
R = (depth > )
nullHash = (hash, zobristSide)
nullScore = -(g, depth - - R, -beta, -beta + , -color, nullHash, ply + )
stopSearch (g, color),
nullScore >= beta beta,
futility =
depth == inCheck alpha > - alpha <
se = (g, color)
se + <= alpha futility =
m = (g, color, , ttMove ~= ttMove , ply)
#m ==
sc
inCheck
baseMate = - + (-depth)*
MODE ==
sc = baseMate *
MODE ==
color == -botSignSearch
victimsLeft =
i=,
pc = g[i]
pc * color > .(pc) ~= victimsLeft = victimsLeft +
victimsLeft > sc = - sc = baseMate *
sc = baseMate
sc = baseMate
sc =
(hash, {depth=depth, score=sc, flag=FLAG_EXACT, move=})
sc,
bestM =
legalMoveCount =
_,mv (m)
stopSearch
isCapture = g[(mv)] ~=
(futility isCapture)
(depth <= ) isCapture inCheck legalMoveCount > + depth*
cap, newHash = (g, mv, hash)
(g,color)
legalMoveCount = legalMoveCount +
gameHashes[newHash] = (gameHashes[newHash] ) +
score
reduce =
depth >= legalMoveCount > cap ==
reduce =
depth >= legalMoveCount > reduce =
legalMoveCount ==
score = -(g, depth-, -beta, -alpha, -color, newHash, ply + )
score = -(g, depth--reduce, -alpha-, -alpha, -color, newHash, ply + )
reduce > score > alpha
score = -(g, depth-, -alpha-, -alpha, -color, newHash, ply + )
score > alpha score < beta
score = -(g, depth-, -beta, -alpha, -color, newHash, ply + )
gameHashes[newHash] = gameHashes[newHash] -
gameHashes[newHash] <= gameHashes[newHash] =
(g,mv,cap)
stopSearch
score > alpha alpha = score; bestM = mv
alpha >= beta
cap == ply
core = (mv)
k = killers[ply]
k k = {,}; killers[ply] = k
k[] ~= core k[] = k[]; k[] = core
f = (mv); t = (mv)
pt = .(g[f])
histTable[pt][t] = histTable[pt][t] + depth*depth
(g,mv,cap)
legalMoveCount ==
stopSearch (g, color),
sc = inCheck (-+(-depth)*)
(hash, {depth=depth, score=sc, flag=FLAG_EXACT, move=})
sc,
stopSearch
flag
alpha <= origAlpha flag = FLAG_UPPER
alpha >= beta flag = FLAG_LOWER
flag = FLAG_EXACT
(hash, {depth=depth, score=alpha, flag=flag, move=bestM})
alpha, bestM ~= bestM
LINES = {}
LINES_COUNT =
LINES_MAX_TOTAL =
LINES_PER_HASH =
LINES_MIN_DEPTH =
(hash, move, score, depth)
depth < LINES_MIN_DEPTH
list = LINES[hash]
list list = {}; LINES[hash] = list; LINES_COUNT = LINES_COUNT +
_, e (list)
e.move == move
depth > e.depth e.depth = depth
.(score) > .(e.score) e.score = score
list[#list+] = { move = move, score = score, depth = depth }
.(list, (a, b) a.depth ~= b.depth a.depth > b.depth a.score > b.score )
#list > LINES_PER_HASH .(list)
LINES_COUNT > LINES_MAX_TOTAL
removed =
k (LINES)
LINES[k] = ; LINES_COUNT = LINES_COUNT - ; removed = removed +
removed >= .(LINES_MAX_TOTAL * )
(hash, g, side)
list = LINES[hash]
list
_, e (list)
from = (e.move, ) +
to = ((e.move, ), ) +
pc = g[from]; tgt = g[to]
pc ~= pc*side > tgt*side <=
g[to] = pc; g[from] =
bad = (g, side)
g[from] = pc; g[to] = tgt
bad e.move, e.depth, e.score
(g, hash, side, maxLen)
pv, saved = {}, {}
curHash, curSide = hash, side
_ = , maxLen
entry = TT[curHash]
entry entry.move ==
from = (entry.move); to = (entry.move)
pc = g[from]
pc == pc * curSide <=
cap = g[to]
cap * curSide >
gameHashes[curHash]
pv[#pv+] = { hash = curHash, move = entry.move, score = entry.score, depth = entry.depth }
curHash = (curHash, zobrist[(from, (pc))])
cap ~= curHash = (curHash, zobrist[(to, (cap))])
curHash = (curHash, zobrist[(to, (pc))])
curHash = (curHash, zobristSide)
g[to] = pc; g[from] =
saved[#saved+] = { from=from, to=to, cap=cap }
curSide = -curSide
i = #saved, , -
s = saved[i]
g[s.from] = g[s.to]; g[s.to] = s.cap
pv
(cur)
(pState)
oppCol=(turn==) -
curPos={}
i=, c=cur[i] c c*oppCol> curPos[i]=c
i=,
prev=pState[i]
prev prev*oppCol> curPos[i]
j=,
curPos[j]==prev
mCount=mCount+
fx=SQ_X[i] fy=SQ_Y[i]
tx=SQ_X[j] ty=SQ_Y[j]
history[#history+]=.(,mCount,(turn==) ,fx,fy,tx,ty)
curPos[j]=
() (turn==) -
()
()
g,models,kings = ()
okBot, okEnemy = (g, models, kings)
okBot okEnemy
()
(g)
side = ()
botSignSearch = side
hash = (g, side)
gameHashes = { [hash] = }
best, bestScore, finalDepth, elapsed = , -.huge, ,
fromLine =
MODE ~=
lineMove, lineDepth, lineScore = (hash, g, side)
lineMove lineDepth >= lineScore >=
best = lineMove; bestScore = lineScore; finalDepth = lineDepth
fromLine = ; elapsed =
best
startTime = .()
nodeCount = ; stopSearch =
killers = {}
p=, t=, histTable[p][t] = .(histTable[p][t] / )
prevBestMove1 =
prevBestMove2 =
maxD = (MODE == )
d = , maxD
delta =
alpha, beta = -.huge, .huge
d > bestScore > - bestScore <
alpha = bestScore - delta; beta = bestScore + delta
currentBestMove =
currentScore = -.huge
score, move = (g, d, alpha, beta, side, hash, )
stopSearch
score <= alpha
alpha = .(-.huge, alpha - delta); delta = delta *
score >= beta
beta = .(.huge, beta + delta); delta = delta *
currentBestMove = move; currentScore = score;
stopSearch
currentBestMove
best = currentBestMove
bestScore = currentScore
finalDepth = d
elapsed = .() - startTime
MODE == d >=
best == prevBestMove1 best == prevBestMove2
prevBestMove2 = prevBestMove1
prevBestMove1 = best
limitFactor = (MODE == )
elapsed > TIME_BUDGET * limitFactor
bestScore > bestScore < -
elapsed = .() - startTime
best
pv = (g, hash, side, )
_, e (pv)
e.score >= (e.hash, e.move, e.score, e.depth)
best
from = (best); to = (best)
tx = SQ_X[to]; ty = SQ_Y[to]
targetCell = bFolder:(tx....ty)
okCell = (targetCell, .(,,), to)
okCell (.(, tx, ty))
model = models[from]
okPiece = (model, .(,,))
okPiece (.(, from))
mCount=mCount+
fx = SQ_X[from]; fy = SQ_Y[from]
tag = fromLine
logStr
fromLine
logStr = .(,
MODE, mCount, turn, fx, fy, tx, ty, finalDepth, bestScore, tag)
logStr = .(,
MODE, mCount, turn, fx, fy, tx, ty, bestScore, finalDepth, nodeCount, elapsed, tag)
history[#history+] = logStr
(logStr)
pState=g
mCount=mCount+
history[#history+]=.(,mCount,turn)
(..turn)
pState=g
isSearching =
(btn)
isSearching
isSearching =
btn btn.Text =
ok, err = (play)
isSearching =
btn btn.Text = .(turn)..
ok (, err)
Players = :()
LP = Players.LocalPlayer
CG:() CG.BotUI:()
CG:() CG.BotSplash:()
LP LP:()
LP.PlayerGui:() LP.PlayerGui.BotUI:()
LP.PlayerGui:() LP.PlayerGui.BotSplash:()
sg=.()
sg.Name=
sg.ResetOnSpawn =
sg.IgnoreGuiInset =
sg.DisplayOrder =
sg.Parent=CG
frame=.()
frame.Size=.(,,,)
frame.Position=.(,-,,-)
frame.BackgroundColor3=.(,,)
frame.BorderSizePixel=
frame.BorderColor3=.(,,)
frame.Active=
frame.Draggable=
frame.Parent=sg
cnr=.()
cnr.CornerRadius=.(,)
cnr.Parent=frame
btnTurn=.()
btnTurn.Size=.(,,,)
btnTurn.Position=.(,,,)
btnTurn.BackgroundColor3=.(,,)
btnTurn.TextColor3=.(,,)
btnTurn.Text=
btnTurn.Font=.Font.SourceSansBold
btnTurn.TextSize=
btnTurn.BorderSizePixel=
btnTurn.Parent=frame
c2=.() c2.CornerRadius=.(,) c2.Parent=btnTurn
btnLog=.()
btnLog.Size=.(,,,)
btnLog.Position=.(,,,)
btnLog.BackgroundColor3=.(,,)
btnLog.TextColor3=.(,,)
btnLog.Text=
btnLog.Font=.Font.SourceSansBold
btnLog.TextSize=
btnLog.BorderSizePixel=
btnLog.Parent=frame
c3=.() c3.CornerRadius=.(,) c3.Parent=btnLog
btnMode=.()
btnMode.Size=.(,,,)
btnMode.Position=.(,,,)
btnMode.BackgroundColor3=MODES[modeIdx].color
btnMode.TextColor3=.(,,)
btnMode.Text= .. MODE
btnMode.Font=.Font.SourceSansBold
btnMode.TextSize=
btnMode.BorderSizePixel=
btnMode.Parent=frame
c4=.() c4.CornerRadius=.(,) c4.Parent=btnMode
btnHelp=.()
btnHelp.Size=.(,,,)
btnHelp.Position=.(,,,)
btnHelp.BackgroundColor3=.(, , )
btnHelp.TextColor3=.(,,)
btnHelp.Text=
btnHelp.Font=.Font.SourceSansBold
btnHelp.TextSize=
btnHelp.BorderSizePixel=
btnHelp.Parent=frame
c5=.() c5.CornerRadius=.(,) c5.Parent=btnHelp
helpFrame = .()
helpFrame.Size = .(, , , )
helpFrame.Position = .(, -, , -)
helpFrame.BackgroundColor3 = .(, , )
helpFrame.BorderSizePixel =
helpFrame.Visible =
helpFrame.ScrollBarThickness =
helpFrame.Parent = sg
helpCorner = .()
helpCorner.CornerRadius = .(, )
helpCorner.Parent = helpFrame
helpText = .()
helpText.Size = .(, -, , )
helpText.Position = .(, , , )
helpText.BackgroundTransparency =
helpText.TextColor3 = .(, , )
helpText.TextXAlignment = .TextXAlignment.Left
helpText.TextYAlignment = .TextYAlignment.Top
helpText.TextWrapped =
helpText.Font = .Font.SourceSans
helpText.TextSize =
helpText.Parent = helpFrame
helpText.Text =
helpBg = .()
helpBg.Size = .(, , , )
helpBg.BackgroundTransparency =
helpBg.Text =
helpBg.Parent = helpFrame
helpBg.MouseButton1Click:(()
helpFrame.Visible =
)
btnHelp.MouseButton1Click:(()
helpFrame.Visible = helpFrame.Visible
)
btnMode.MouseButton1Click:(()
modeIdx = modeIdx % #MODES +
MODE = MODES[modeIdx].name
TIME_BUDGET = MODES[modeIdx].time
btnMode.Text = .. MODE
btnMode.BackgroundColor3 = MODES[modeIdx].color
LINES = {}; LINES_COUNT =
TT = {}
(.(, MODE, TIME_BUDGET))
)
UIS.InputBegan:((i,gpe)
gpe i.KeyCode==.KeyCode.R (btnTurn)
)
btnTurn.MouseButton1Click:(()
turn=(turn==)
btnTurn.Text=.(turn)..
btnTurn.BackgroundColor3=(turn==) .(,,) .(,,)
btnTurn.TextColor3=(turn==) .(,,) .(,,)
pState={}
(btnTurn)
)
btnLog.MouseButton1Click:(()
#history== btnLog.Text= .() btnLog.Text=
txt=.(history,)
setcl (txt) btnLog.Text= (txt) btnLog.Text=
.() btnLog.Text=
)
splash = .()
splash.Name =
splash.ResetOnSpawn =
splash.IgnoreGuiInset =
splash.DisplayOrder =
splash.Parent = CG
sFrame = .()
sFrame.Size = .(, , , )
sFrame.Position = .(, -, , -)
sFrame.BackgroundColor3 = .(, , )
sFrame.BorderSizePixel =
sFrame.Parent = splash
sCorner = .()
sCorner.CornerRadius = .(, )
sCorner.Parent = sFrame
sText = .()
sText.Size = .(, -, , -)
sText.Position = .(, , , )
sText.BackgroundTransparency =
sText.TextColor3 = .(, , )
sText.TextXAlignment = .TextXAlignment.Left
sText.TextYAlignment = .TextYAlignment.Top
sText.TextWrapped =
sText.Font = .Font.SourceSans
sText.TextSize =
sText.Text =
sText.Parent = sFrame
sBg = .()
sBg.Size = .(, , , )
sBg.BackgroundTransparency =
sBg.Text =
sBg.ZIndex =
sBg.Parent = sFrame
sBg.MouseButton1Click:(()
splash:()
.(()
(btnTurn)
)
)
)♟️ CHESS! - Advanced Custom Chess Bot ♟️ Play chess against a fully custom, homebrew AI bot directly inside Roblox! ⭐ FEATURES: • 5 Unique Modes: BALANCED, MATE, GENOCIDE, ADAPTIVE, and SOLID. • Move Highlighting: Green shows where to move, Blue shows which piece to move. • Auto-Logging: Copy the entire game history to your clipboard. • Built-in Guide: Detailed tutorial and mode descriptions inside the GUI. ⚠️ IMPORTANT TO KNOW: • This is a CUSTOM bot written from scratch. It does NOT use external servers or Stockfish. • Because it runs entirely on the client-side (Luau), it might take a few seconds to think. Small freezes or lag during its turn are COMPLETELY NORMAL. The ADAPTIVE mode can think for up to 60 seconds. • Use ONLY default piece skins! Custom or weird-colored meshes can break the bot's piece detection logic. • It is designed as a HELPER. It gives you suggestions but cannot replace human intelligence. Play fair and have fun! 🛠️ OPEN SOURCE: This script is completely free and open source. Anyone can use, modify, or learn from it. Source code is available on GitHub: https://raw.githubusercontent.com/Kirill73384/h4j56k5j/refs/heads/main/CHESS!!.lua 🚀 HOW TO USE: 1
🍀Hard Time