Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::: [ * Author: T3RRY * ] Creation Date - 12/01/2021 ::: WINDOWS 10 only
- @Echo off & mode 50,11
- For /F %%a in ('echo prompt $E ^| cmd')do Set "\E=%%a"
- Set LF=^
- %= ! linefeed var. Do not remove or modify this line or above 2 lines ! =%
- IF "!!" == "" ( Echo DelayedExpansion should not be enabled yet&Pause & Goto:EOF )
- Set Grid=^<nul Set /P =%\E%[2;13H%\E%[37mDraw %\E%[34mWin %\E%[33mLose%\E%[5;1H^
- !Spacer!%\E%[?25l%\E%[35m[%\E%[32m!c7:7=%\E%[90m7!%\E%[35m][%\E%[32m!c8:8=%\E%[90m8!%\E%[35m][%\E%[32m!c9:9=%\E%[90m9!%\E%[35m]!LF!^
- !Spacer![%\E%[32m!c4:4=%\E%[90m4!%\E%[35m][%\E%[32m!c5:5=%\E%[90m5!%\E%[35m][%\E%[32m!c6:6=%\E%[90m6!%\E%[35m]!LF!^
- !Spacer![%\E%[32m!c1:1=%\E%[90m1!%\E%[35m][%\E%[32m!c2:2=%\E%[90m2!%\E%[35m][%\E%[32m!c3:3=%\E%[90m3!%\E%[35m]%\E%[0m
- Set "Reset=( Title #. Game over. ) & Timeout /t 3 /Nobreak > nul & Endlocal & Goto :start"
- Set "?.Cells=For %%V in ("!c1!!c4!!c7!" "!c2!!c5!!c8!" "!c3!!c6!!c9!" "!c1!!c2!!c3!" "!c4!!c5!!c6!" "!c7!!c8!!c9!" "!c3!!c5!!c7!" "!c1!!c5!!c9!")Do "
- :start
- CLS
- Setlocal EnableExtensions EnableDelayedExpansion
- %!! priority =%
- Set "Cho= 5 1 3 7 9 2 4 6 8"
- Set "turn=9"
- For /L %%n in (1 1 9)Do Set "c%%n=%%n"
- Set "Spacer="
- For /L %%n in (0 1 18)Do Set "Spacer= !Spacer!"
- For /F "Delims=" %%v in ('set /A "!random! %%2 + 1"')Do Goto:p%%v
- :p1
- %GRID% & TITLE Enter a number - Available: %Cho% or [E]xit
- For /F "Delims=" %%G in ('Choice /N /C:%Cho: =%e')Do (
- Set "c%%G=X"& Set "Cho=!Cho: %%G=!"& Set /A turn-=1
- If /I "%%G" == "E" (
- Endlocal
- Exit /b 0))
- TITLE Tic Tac Toe & %?.Cells% If "%%~V" == "XXX" Goto :Win
- :p2
- %GRID:32=31%
- Set "move="&Set "line="& %?.Cells% For %%c in (X O)Do (
- Set "line=%%~V"
- For /L %%n in (1 1 9)Do ( %= Test ideal move; Priority - Take win ; block player =%
- Set "line=!line:%%n%%c%%c=!"
- If not "!line!" == "" Set "line=!line:%%c%%n%%c=!"
- If not "!line!" == "" Set "line=!line:%%c%%c%%n=!"
- If "!line!" == "" (Set "move=%%n")))
- Call :AI && %?.Cells% If "%%~V" == "OOO" Goto :Lose
- For /l %%. in (1 1 150000)Do rem
- If !turn! LEQ 0 (
- %GRID:32=37%
- Timeout /T 2 > nul
- %Reset:#=Draw%
- )Else Goto p1
- :AI %= Enact best available move option - win; block player win; centre; corners; mid-outers =%
- %!! filled by AI; GT# is Game turn Number =%
- If not "%move%" == "" (
- Set "c%move%=O" & Set "Cho=!Cho: %move%=!" & Set /A "turn-=1"
- Exit /B 0)
- For %%i in (%Cho%)DO (
- Set "tCho=!Cho:%%i=!"
- If Not "!tCho!" == "!Cho!" (
- Set "c%%i=O" & Set "Cho=!Cho: %%i=!" & Set /A "turn-=1"
- Exit /B 0))
- If !turn! EQU 0 Exit /B 0
- :Win
- %Grid:32=34%
- Timeout /T 2 > nul
- %Reset:#=You Won%
- :Lose
- %Grid:32=33%
- Timeout /T 2 > nul
- %Reset:#=You Lost%
Add Comment
Please, Sign In to add comment