JustDoesGames

Tic Tac Toe in 1kb (compressed)

Sep 8th, 2020 (edited)
1,268
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. assert(term.isColor(),"Adv. Needed")local a,b,c,d,e,f,g,h,i,j,k,l,m=term.clear,term.setCursorPos,term.setTextColor,term.setBackgroundColor,print,0,3,"000000000","123456789147258369159357",{"x","o"}c(colors.white)d(colors.black)a()local function n(k,o)return tonumber(k:sub(o,o))end;local function p()k=1;for q=1,3 do for r=1,3 do b(r,q)e(j[n(h,k)]or"-")k=k+1 end end end;local function s()for q=1,2 do for t=1,8 do if n(h,n(i,t*3-2))==q and n(h,n(i,t*3-1))==q and n(h,n(i,t*3))==q then g=q end end end end;p()while g>2 and f<5 do repeat _,_,l,m=os.pullEvent("mouse_click")until l<4 and m<4 and n(h,(m-1)*3+l)<1;h=h:sub(1,(m-1)*3+l-1).."1"..h:sub((m-1)*3+l+1)s()if f~=4 and g>2 then repeat k=math.random(1,9)until n(h,k)<1;h=h:sub(1,k-1).."2"..h:sub(k+1)end;s()p()f=f+1 end;if g>0 then e(({"Win","Lost"})[g]or"Tie")end
RAW Paste Data