Wednesday, November 17, 2010

Batch game - Splat the rat source code

@echo off
if /i "%1"=="Attrib" (
goto checkhighscore.txt
)
if /i "%1"=="Countermode" (
goto countermode
)
title Splat-The-Rat
setlocal enabledelayedexpansion
for %%I in (%0) do set filename=%%~sI
if exist highscore.txt (
start /MIN CMD.exe /c "%FILENAME% Attrib"
)
if exist info.dat del info.dat
:menu
title Splat-The-Rat
cls
echo Main Menu
echo ---------
echo.
echo To play a game, enter 1
echo For instructions, enter 2
echo For Highscores, enter 3
echo To exit, enter 4
set menu=
set /p menu=""
if not defined menu goto menu
if %menu%==1 (goto startgame)
if %menu%==2 (goto instructions)
if %menu%==3 (goto Displayscores)
if %menu%==4 (exit /b)
goto menu

:checkhighscore.txt
attrib highscore.txt | find "SHR" >nul
if %errorlevel%==0 (exit)
attrib highscore.txt +S +H +R
exit

:instructions
cls
echo Splat The Rat
echo -------------
echo The aim of the game is to hit the rat with your club as soon as it
echo pops out of its hole. You can try hitting the rat
echo with the quickest reaction time, or hit as many rats in a row as
echo possible. Your score is recorded in the same directory as the game
echo file.
echo.
echo.
echo Press any key for the next page
pause>nul
cls
echo Splat The Rat
echo -------------
echo As soon as you start the game one extra window will appear, titled
echo 'Rat Window' this window shows the activity of the rat. As soon as
echo the window appears it should be dragged away from the original
echo Bat Window to allow you to see both. You should then click on the
echo Bat Window to allow you to use your bat.
echo.
echo.
echo Press any key for the next page
pause>nul
cls
echo Splat The Rat
echo -------------
echo To hit the rat, have the Bat Window selected, and press any key as soon
echo as you see the rat appear on the Rat Window.
echo.
echo.
echo Press any key to go to the main menu.
pause>nul
goto menu


:displayscores
cls
if not exist highscore.txt (
echo No high scores yet.
echo.
echo Press any key to return to menu
pause>nul
goto menu
)
find /i "Fastest-Single-Reaction=" Highscore.txt >nul
set count=%errorlevel%
find /i "Most-Rats-Hit=" Highscore.txt >nul
set /a count= %count% + %errorlevel%
find /i "Best-Average-Reaction=" Highscore.txt >nul
set /a count= %count% + %errorlevel%
if %count%==3 (
echo High Score File Incorrect
echo.
echo Press any key to return to menu
pause>nul
goto menu
)
echo High Scores
echo -----------
echo.
type highscore.txt | find /i "fastest-Single-Reaction"
type highscore.txt | find /i "Most-Rats-Hit"
type highscore.txt | find /i "Best-Average-Reaction"
echo.
echo.
echo Press any key to return to menu
pause>nul
goto menu



:startgame
title Bat Window
cls
set fastestreaction=999
set SN=0
set totalmil=0
set offset=10
echo nul >info.dat
start cmd /c "%filename% Countermode"
Echo Move the Rat window so you can see both windows, then click
echo this window.
echo.
echo Press any key to begin the game
pause>nul
echo START >info.dat
cls
echo Press Any Key To Swing Your Bat!
Pause>nul
set swingtime=%time:~2%
echo Y%SN%-%swingtime% >>info.dat


:result
find /i "w%SN%" info.dat >nul
if %errorlevel%==0 (
cls
set /a sn= %SN% + 1
goto Swingagain
)
find /i "l" info.dat >nul
if %errorlevel%==0 (
cls
echo Game Over
goto gotresult
)
goto result

:swingagain
echo Good Hit
if %sn%==1 (
echo Got 1 rat so far
) else (
echo Got %sn% rats so far
)

:processreactiontime
if %sn% geq 11 set offset=11
if %sn% geq 101 set offset=12
set x=1
for /f %%A in (info.dat) do set data=%%A & call :Setswingtime
set x=1
for /f %%A in (info.dat) do set data=%%A & call :Setfalltime
set /a CFN= ( %sn% * 3 ) - 1
set /a CSN= %sn% * 3
set truefalltime=!falltime%CFN%!
set truefalltime=!truefalltime:~%offset%,2!
set trueswingtime=!swingtime%CSN%!
set trueswingtime=!trueswingtime:~%offset%,2!
if /i %trueswingtime%==08 (
set trueswingtime=8
)
if /i %trueswingtime%==09 (
set trueswingtime=9
)
if /i %truefalltime%==08 (
set truefalltime=8
)
if /i %truefalltime%==09 (
set truefalltime=9
)
set /a reactionmil= %trueswingtime% - %truefalltime%
if /i %reactionmil% lss 0 (
set /a reactionmil= %reactionmil% + 100
)
if /i %reactionmil% leq 9 (
echo Your reaction time was 0.0%reactionmil% Seconds
) else (
echo Your reaction time was 0.%reactionmil% Seconds
)
goto continueswingagain

:setswingtime
set Swingtime%x%=%data%
set /a x= %x% + 1
exit /b

:setfalltime
set falltime%x%=%data%
set /a x= %x% + 1
exit /b

:continueswingagain
echo.
echo Press Any Key To Swing Your Bat
pause>nul
set swingtime=%time:~2%
echo Y%SN%-%swingtime% >>info.dat
set /a totalmil= %totalmil% + %reactionmil%
if not defined fastestreaction (set fastestreaction=%reactionmil%)
if /i %fastestreaction% gtr %reactionmil% (
set fastestreaction=%reactionmil%
)
goto result


:Gotresult
if %sn% equ 0 (
echo Sorry, you didn't get any rats
goto moreresults
)
if %sn% equ 1 (
echo Sorry, you only got one rat
goto Moreresults
)
if /i %sn% leq 3 (
echo Sorry, you only got %sn% rats
) else (
echo Well done, you got %sn% rats
)
:moreresults
find /i info.dat "LL" >nul
if /i %errorlevel% equ 0 (
Echo On that last one, you were too slow, he got away.
) else (
echo On that last one, you swung too soon.
)
IF %sn%==0 goto end
:processrats
set /a averagetime= %totalmil% / %sn%
echo You got %sn% rats
echo Your average reaction time was 0.%averagetime% seconds
if /i %fastestreaction% leq 9 (
echo Your reaction time was 0.0%fastestreaction% Seconds
) else (
echo Your reaction time was 0.%fastestreaction% Seconds
)
if not exist highscore.txt goto noscorelist
goto scorelistexists

:noscorelist
set most=1
set best=1
set fastest=1
goto changescore

:scorelistexists
set most=
set fastest=
set best=
find /i "Most-Rats-Hit" Highscore.txt >nul
if /i NOT %errorlevel% equ 0 (
set Most=1
)
find /i "Fastest-Single-Reaction" Highscore.txt >nul
if /i NOT %errorlevel% equ 0 (
set Fastest=1
)
find /i "Best-Average-reaction" Highscore.txt >nul
if /i NOT %errorlevel% equ 0 (
set Best=1
)
goto Mustcompare

:Mustcompare
for /f %%A in (highscore.txt) do set data=%%A & call :RHset
set sorted=
for /f %%A in (highscore.txt) do set data=%%A & call :BAset
set sorted=
for /f %%A in (highscore.txt) do set data=%%A & call :FRset
set sorted=
set oldRH=%oldRH:~20%
set oldBA=%oldBA:~30,2%
set oldFR=%oldFR:~32,2%
goto comparetime

:rhset
set variable=OldRH
set keyword=Most
call :sortvariables
exit /b

:baset
set variable=OldBA
set keyword=Best
call :sortvariables
exit /b

:frset
set variable=OldFR
set keyword=Fastest
call :sortvariables
exit /b

:sortvariables
if defined sorted (goto endsortvariables)
set %variable%=%data%
echo !%variable%! | find /i "%keyword%" >nul
if NOT errorlevel 1 (
set sorted=1
) else (
set %variable%=
)
:endsortvariables
exit /b

:comparetime
if defined fastest goto alreadyfastest
if /i %fastestreaction% lss %oldfr% (
set fastest=1
)
:alreadyfastest
if defined Most goto alreadymost
if /i %oldRH% lss %SN% (
set Most=1
)
:alreadymost
if defined best goto alreadybest
if /i %averagetime% lss %OldBA% (
set Best=1
)
:alreadybest
if defined best goto Changescore
if defined most goto Changescore
if defined fastest goto Changescore
goto end

:changescore
echo.
Echo New High Score!
echo ---------------
echo New Score In:
echo.
if defined most (
echo Most Rats Hit
)
if defined best (
echo Best Average Time
)
if defined fastest (
echo Fastest Single Reaction
)
echo.
set initials=
echo Please Enter Your Initials (3 Characters Maximum)
set /p initials=""
IF NOT defined initials (
cls
goto changescore
)
if "%initials:~1%"=="" (
set initials=%initials%--
)
if "%initials:~2%"=="" (
set initials=%initials%-
)
set initials=%initials:~0,3%

if defined most goto editmost
goto checkeditbest

:editmost
if /i %fastestreaction% leq 9 (
set fastestreaction=0%fastestreaction%
)
if exist highscore.txt (
type highscore.txt | find /i /v "most-rats-hit" >Highscore
attrib highscore.txt -s -h -r
type highscore >Highscore.txt
attrib highscore.txt +s +h +r
del highscore
attrib highscore.txt -s -h -r
echo %initials%---Most-Rats-Hit=%sn% >>Highscore.txt
attrib highscore.txt +s +h +r
) else (
echo %initials%---Most-Rats-Hit=%sn% >>Highscore.txt
attrib highscore.txt +s +h +r
)

:checkeditbest
if defined best goto editbest
goto checkeditfastest

:editbest
if exist highscore.txt (
type highscore.txt | find /i /v "best-average-reaction" >Highscore
attrib highscore.txt -s -h -r
type highscore >Highscore.txt
attrib highscore.txt +s +h +r
del highscore
attrib highscore.txt -s -h -r
echo %initials%---Best-Average-Reaction=0.%averagetime% >>Highscore.txt
attrib highscore.txt +s +h +r
) else (
echo %initials%---Best-Average-Reaction=0.%averagetime% >>Highscore.txt
attrib highscore.txt +s +h +r
)

:checkeditfastest
if defined fastest goto editfastest
goto scoresedited

:editfastest
if exist highscore.txt (
type highscore.txt | find /i /v "Fastest-Single-Reaction" >Highscore
attrib highscore.txt -s -h -r
type highscore >Highscore.txt
attrib highscore.txt +s +h +r
del highscore
attrib highscore.txt -s -h -r
echo %initials%---Fastest-Single-Reaction=0.%fastestreaction% >>Highscore.txt
attrib highscore.txt +s +h +r
) else (
echo %initials%---Fastest-Single-Reaction=0.%fastestreaction% >>Highscore.txt
attrib highscore.txt +s +h +r
)

:Scoresedited
echo Scores Saved
echo.
goto end


:end
del info.dat
pause>nul

:playagain
echo Go to menu? (Y/N)
:playagain1
set choice=
set /p choice=""
if /i "%choice:~0,1%"=="Y" (
goto menu
)
if /i "%choice:~0,1%"=="N" (
exit /b
)
goto playagain


::###################################################################

:COUNTERMODE
@echo off
color f0
title Rat Window
setlocal enabledelayedexpansion
echo Move this window so you can see both windows.
echo Have the Bat window selected and press any key to begin the game
:waittostart
type info.dat | find /i "start" >nul
if %errorlevel%==0 (goto TimeTostart) else (goto waittostart)
:TimeToStart
set timestart=%time:~2%
echo X%timestart% >info.dat
set SN=-1
set w=0
cls
goto timesetup


:1
find info.dat "Y%sn%" >nul
if %errorlevel%==0 goto stop
if /i %time:~6,2% equ %timechange% goto ShowRat
goto noRats

:ShowRat
set ztime%sn%=Z%sn%-%time:~2%
cls
call :showrat
set w=1
set timechange=CHANGE_DONE
echo !ztime%sn%! >>info.dat

:noRats
if /i %time:~6,2% equ %timeback% (
cls
call :norat
echo.
echo You missed the rat!
echo Swing your bat to end the game.
set w=0
set timeback=CHANGE_DONE
set L=L
)
goto 1

:STOP
if /i %w%==1 (
echo W%sn% >>info.dat
) else (
echo L%L% >>info.dat
exit /b
)

:Timesetup
cls
call :norat
set w=0
set /a sn= %sn% + 1
set timestart=%time:~2%
set timechange=%timestart:~4,2%
if /i %timechange% equ 08 (set timechange=8)
if /i %timechange% equ 09 (set timechange=9)
set /a timechange= %timechange% + 2 + %random:~1,1%
if %timechange% geq 60 (
set /a timechange= %timechange% - 60
)
set /a timeback= %timechange% + 1
if %timeback% geq 60 (
set /a timeback=%timeback% - 60
)
if /i %timechange% equ 8 (
set timechange=08
)
if /i %timechange% equ 9 (
set timechange=09
)
if /i %timeback% equ 8 (
set timeback=08
)
if /i %timeback% equ 9 (
set timeback=09
)

goto 1


:NORAT
echo __ __ __ __ __ __ __ __ __
echo [__][__][__][__][__][__][__][__][__]
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__]
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__]
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__][__][__][__][__][__][__]
echo ____________________________________
exit /b

:showrat
echo __ __ __ __ __ __ __ __ __
echo [__][__][__][__][__][__][__][__][__]
echo _][__][__][__][__][__][__][__][__][_
echo [__][__][__] __ __ _][__][__][__]
echo _][__][__] (_.)__(._) __][__][__][_
echo [__][__][__] (- -) _][__][__][__]
echo _][__][__][ --{()}-- [__][__][__][_
echo [__][__][__] (____) _][__][__][__]
echo ______________''__''________________
exit /b

Sunday, November 7, 2010

Batch game - Connect four (Source Code)

@echo off
title Connect Four By Mastahhaxor
color 1A
:titlescreen
color 0A
cls
Echo.
Echo.
Echo *************************************************
Echo.
Echo ##### # #
Echo # # # #
Echo # ## ## ## #### ### ### #####
Echo # # # # # # # # # # #
Echo ##### ## # # # # #### ### # #
Echo.
Echo *************************************************
Echo.
Echo By Mastahhaxor
Echo.
Echo.
Echo 1)Play Game
Echo 2)Instructions
Echo.
Echo.
set /p choice=
If %choice% EQU 1 goto superstart else goto titlescreen
If %choice% EQU 2 goto Instruct
:instruct
cls
Echo.
Echo.
Echo The goal of this game is to get four of your pieces in a row.
Echo in any direction. To choose a column to place your piece in
Echo type in the letter that corresponds with it (lowercase only).
Echo You must stack pieces in each column so the bottom will always
Echo fill up first. Enjoy! By the way, I do not claim to own Connect Four,
Echo this is just my representation of it.
Echo.
Echo.
pause
goto :superstart

:superstart
color 0E
cls
Echo.
Echo.
Echo Who will play X's?
Echo.
set /p xs=
cls
Echo.
Echo.
Echo And who will play O's?
Echo.
set /p os=
set /a scorex=0
set /a scoreo=0
set /a draw=0
set /a turns=0
:start
set a1=_
set a2=_
set a3=_
set a4=_
set a5=_
set b1=_
set b2=_
set b3=_
set b4=_
set b5=_
set c1=_
set c2=_
set c3=_
set c4=_
set c5=_
set d1=_
set d2=_
set d3=_
set d4=_
set d5=_
set e1=_
set e2=_
set e3=_
set e4=_
set e5=_
set f1=_
set f2=_
set f3=_
set f4=_
set f5=_


:map1
cls
Echo.
Echo.
Echo Score: %xs%:%scorex%
Echo %os%:%scoreo%
Echo Draw:%draw%
Echo.
Echo.
Echo A B C D E F
Echo *[%a1%] [%b1%] [%c1%] [%d1%] [%e1%] [%f1%]*
Echo * *
Echo *[%a2%] [%b2%] [%c2%] [%d2%] [%e2%] [%f2%]*
Echo * *
Echo *[%a3%] [%b3%] [%c3%] [%d3%] [%e3%] [%f3%]*
Echo * *
Echo *[%a4%] [%b4%] [%c4%] [%d4%] [%e4%] [%f4%]*
Echo * *
Echo *[%a5%] [%b5%] [%c5%] [%d5%] [%e5%] [%f5%]*
Echo.
goto P1

:map2
cls
Echo.
Echo.
Echo Score: %xs%:%scorex%
Echo %os%:%scoreo%
Echo Draw:%draw%
Echo.
Echo.
Echo A B C D E F
Echo *[%a1%] [%b1%] [%c1%] [%d1%] [%e1%] [%f1%]*
Echo * *
Echo *[%a2%] [%b2%] [%c2%] [%d2%] [%e2%] [%f2%]*
Echo * *
Echo *[%a3%] [%b3%] [%c3%] [%d3%] [%e3%] [%f3%]*
Echo * *
Echo *[%a4%] [%b4%] [%c4%] [%d4%] [%e4%] [%f4%]*
Echo * *
Echo *[%a5%] [%b5%] [%c5%] [%d5%] [%e5%] [%f5%]*
Echo.
goto P2R

:P1c
If %a1%+%a2%+%a3%+%a4% EQU O+O+O+O goto wino
If %a5%+%a2%+%a3%+%a4% EQU O+O+O+O goto wino
If %b1%+%b2%+%b3%+%b4% EQU O+O+O+O goto wino
If %b5%+%b2%+%b3%+%b4% EQU O+O+O+O goto wino
If %c1%+%c2%+%c3%+%c4% EQU O+O+O+O goto wino
If %c5%+%c2%+%c3%+%c4% EQU O+O+O+O goto wino
If %d1%+%d2%+%d3%+%d4% EQU O+O+O+O goto wino
If %d5%+%d2%+%d3%+%d4% EQU O+O+O+O goto wino
If %e1%+%e2%+%e3%+%e4% EQU O+O+O+O goto wino
If %e5%+%e2%+%e3%+%e4% EQU O+O+O+O goto wino
If %f1%+%f2%+%f3%+%f4% EQU O+O+O+O goto wino
If %f5%+%f2%+%f3%+%f4% EQU O+O+O+O goto wino
If %a1%+%b1%+%c1%+%d1% EQU O+O+O+O goto wino
If %e1%+%b1%+%c1%+%d1% EQU O+O+O+O goto wino
If %e1%+%f1%+%c1%+%d1% EQU O+O+O+O goto wino
If %a2%+%b2%+%c2%+%d2% EQU O+O+O+O goto wino
If %e2%+%b2%+%c2%+%d2% EQU O+O+O+O goto wino
If %e2%+%f2%+%c2%+%d2% EQU O+O+O+O goto wino
If %a3%+%b3%+%c3%+%d3% EQU O+O+O+O goto wino
If %e3%+%b3%+%c3%+%d3% EQU O+O+O+O goto wino
If %e3%+%f3%+%c3%+%d3% EQU O+O+O+O goto wino
If %a4%+%b4%+%c4%+%d4% EQU O+O+O+O goto wino
If %e4%+%b4%+%c4%+%d4% EQU O+O+O+O goto wino
If %e4%+%f4%+%c4%+%d4% EQU O+O+O+O goto wino
If %a5%+%b5%+%c5%+%d5% EQU O+O+O+O goto wino
If %e5%+%b5%+%c5%+%d5% EQU O+O+O+O goto wino
If %e5%+%f5%+%c5%+%d5% EQU O+O+O+O goto wino
If %a2%+%b3%+%c4%+%d5% EQU O+O+O+O goto wino
If %a1%+%b2%+%c3%+%d4% EQU O+O+O+O goto wino
If %e5%+%b2%+%c3%+%d4% EQU O+O+O+O goto wino
If %b1%+%c2%+%d3%+%e4% EQU O+O+O+O goto wino
If %f5%+%c2%+%d3%+%e4% EQU O+O+O+O goto wino
If %c1%+%d2%+%e3%+%f4% EQU O+O+O+O goto wino
If %c5%+%d4%+%e3%+%f2% EQU O+O+O+O goto wino
If %c5%+%d4%+%e3%+%f2% EQU O+O+O+O goto wino
If %b5%+%c4%+%d3%+%e2% EQU O+O+O+O goto wino
If %f1%+%c4%+%d3%+%e2% EQU O+O+O+O goto wino
If %a5%+%b4%+%c3%+%d2% EQU O+O+O+O goto wino
If %e1%+%b4%+%c3%+%d2% EQU O+O+O+O goto wino
If %a4%+%b3%+%c2%+%d1% EQU O+O+O+O goto wino
If %turns% EQU 30 goto draw
goto map1

:P1
Echo.
Echo.
Echo %xs%, it's your turn.
Echo.
Echo.
set /p x=
If %x% EQU a goto A5
If %x% EQU b goto B5
If %x% EQU c goto C5
If %x% EQU d goto D5
If %x% EQU e goto E5
If %x% EQU f goto F5
goto Map1

:A5
If %a5% EQU X goto A4
If %a5% EQU O goto A4
set a5=X
goto P2

:A4
If %a4% EQU X goto A3
If %a4% EQU O goto A3
set a4=X
goto P2

:A3
If %a3% EQU X goto A2
If %a3% EQU O goto A2
set a3=X
goto P2

:A2
If %a2% EQU X goto A1
If %a2% EQU O goto A1
set a2=X
goto P2

:A1
If %a1% EQU X goto error1
If %a1% EQU O goto error1
set a1=X
goto P2



:B5
If %b5% EQU X goto B4
If %b5% EQU O goto B4
set b5=X
goto P2

:B4
If %b4% EQU X goto B3
If %b4% EQU O goto B3
set b4=X
goto P2

:B3
If %b3% EQU X goto B2
If %b3% EQU O goto B2
set b3=X
goto P2

:B2
If %b2% EQU X goto B1
If %b2% EQU O goto B1
set b2=X
goto P2

:B1
If %b1% EQU X goto error1
If %b1% EQU O goto error1
set b1=X
goto P2



:C5
If %c5% EQU X goto C4
If %c5% EQU O goto C4
set c5=X
goto P2

:C4
If %c4% EQU X goto C3
If %c4% EQU O goto C3
set c4=X
goto P2

:C3
If %c3% EQU X goto C2
If %c3% EQU O goto C2
set c3=X
goto P2

:C2
If %c2% EQU X goto C1
If %c2% EQU O goto C1
set c2=X
goto P2

:C1
If %c1% EQU X goto error1
If %c1% EQU O goto error1
set c1=X
goto P2


:D5
If %d5% EQU X goto D4
If %d5% EQU O goto D4
set d5=X
goto P2

:D4
If %d4% EQU X goto D3
If %d4% EQU O goto D3
set d4=X
goto P2

:D3
If %d3% EQU X goto D2
If %d3% EQU O goto D2
set d3=X
goto P2

:D2
If %d2% EQU X goto D1
If %d2% EQU O goto D1
set d2=X
goto P2

:D1
If %d1% EQU X goto error1
If %d1% EQU O goto error1
set d1=X
goto P2


:E5
If %e5% EQU X goto E4
If %e5% EQU O goto E4
set e5=X
goto P2

:E4
If %e4% EQU X goto E3
If %e4% EQU O goto E3
set e4=X
goto P2

:E3
If %e3% EQU X goto E2
If %e3% EQU O goto E2
set e3=X
goto P2

:E2
If %e2% EQU X goto E1
If %e2% EQU O goto E1
set e2=X
goto P2

:E1
If %e1% EQU X goto error1
If %e1% EQU O goto error1
set e1=X
goto P2

:F5
If %f5% EQU X goto F4
If %f5% EQU O goto F4
set f5=X
goto P2

:F4
If %f4% EQU X goto F3
If %f4% EQU O goto F3
set f4=X
goto P2

:F3
If %f3% EQU X goto F2
If %f3% EQU O goto F2
set f3=X
goto P2

:F2
If %f2% EQU X goto F1
If %f2% EQU O goto F1
set f2=X
goto P2

:F1
If %f1% EQU X goto error1
If %f1% EQU O goto error1
set f1=X
goto P2




:P2
If %a1%+%a2%+%a3%+%a4% EQU X+X+X+X goto winx
If %a5%+%a2%+%a3%+%a4% EQU X+X+X+X goto winx
If %b1%+%b2%+%b3%+%b4% EQU X+X+X+X goto winx
If %b5%+%b2%+%b3%+%b4% EQU X+X+X+X goto winx
If %c1%+%c2%+%c3%+%c4% EQU X+X+X+X goto winx
If %c5%+%c2%+%c3%+%c4% EQU X+X+X+X goto winx
If %d1%+%d2%+%d3%+%d4% EQU X+X+X+X goto winx
If %d5%+%d2%+%d3%+%d4% EQU X+X+X+X goto winx
If %e1%+%e2%+%e3%+%e4% EQU X+X+X+X goto winx
If %e5%+%e2%+%e3%+%e4% EQU X+X+X+X goto winx
If %f1%+%f2%+%f3%+%f4% EQU X+X+X+X goto winx
If %f5%+%f2%+%f3%+%f4% EQU X+X+X+X goto winx
If %a1%+%b1%+%c1%+%d1% EQU X+X+X+X goto winx
If %e1%+%b1%+%c1%+%d1% EQU X+X+X+X goto winx
If %e1%+%f1%+%c1%+%d1% EQU X+X+X+X goto winx
If %a2%+%b2%+%c2%+%d2% EQU X+X+X+X goto winx
If %e2%+%b2%+%c2%+%d2% EQU X+X+X+X goto winx
If %e2%+%f2%+%c2%+%d2% EQU X+X+X+X goto winx
If %a3%+%b3%+%c3%+%d3% EQU X+X+X+X goto winx
If %e3%+%b3%+%c3%+%d3% EQU X+X+X+X goto winx
If %e3%+%f3%+%c3%+%d3% EQU X+X+X+X goto winx
If %a4%+%b4%+%c4%+%d4% EQU X+X+X+X goto winx
If %e4%+%b4%+%c4%+%d4% EQU X+X+X+X goto winx
If %e4%+%f4%+%c4%+%d4% EQU X+X+X+X goto winx
If %a5%+%b5%+%c5%+%d5% EQU X+X+X+X goto winx
If %e5%+%b5%+%c5%+%d5% EQU X+X+X+X goto winx
If %e5%+%f5%+%c5%+%d5% EQU X+X+X+X goto winx
If %a2%+%b3%+%c4%+%d5% EQU X+X+X+X goto winx
If %a1%+%b2%+%c3%+%d4% EQU X+X+X+X goto winx
If %e5%+%b2%+%c3%+%d4% EQU X+X+X+X goto winx
If %b1%+%c2%+%d3%+%e4% EQU X+X+X+X goto winx
If %f5%+%c2%+%d3%+%e4% EQU X+X+X+X goto winx
If %c1%+%d2%+%e3%+%f4% EQU X+X+X+X goto winx
If %c5%+%d4%+%e3%+%f2% EQU X+X+X+X goto winx
If %c5%+%d4%+%e3%+%f2% EQU X+X+X+X goto winx
If %b5%+%c4%+%d3%+%e2% EQU X+X+X+X goto winx
If %f1%+%c4%+%d3%+%e2% EQU X+X+X+X goto winx
If %a5%+%b4%+%c3%+%d2% EQU X+X+X+X goto winx
If %e1%+%b4%+%c3%+%d2% EQU X+X+X+X goto winx
If %a4%+%b3%+%c2%+%d1% EQU X+X+X+X goto winx
If %turns% EQU 30 goto draw
goto map2


:P2R
Echo.
Echo.
Echo %os%, it's your turn.
Echo.
Echo.
set /p x=
If %x% EQU a goto A5o
If %x% EQU b goto B5o
If %x% EQU c goto C5o
If %x% EQU d goto D5o
If %x% EQU e goto E5o
If %x% EQU f goto F5o
goto Map2

:A5o
If %a5% EQU X goto A4o
If %a5% EQU O goto A4o
set a5=O
goto P1c

:A4o
If %a4% EQU X goto A3o
If %a4% EQU O goto A3o
set a4=O
goto P1c

:A3o
If %a3% EQU X goto A2o
If %a3% EQU O goto A2o
set a3=O
goto P1c

:A2o
If %a2% EQU X goto A1o
If %a2% EQU O goto A1o
set a2=O
goto P1c

:A1o
If %a1% EQU X goto error2
If %a1% EQU O goto error2
set a1=O
goto P1c



:B5o
If %b5% EQU X goto B4o
If %b5% EQU O goto B4o
set b5=O
goto P1c

:B4o
If %b4% EQU X goto B3o
If %b4% EQU O goto B3o
set b4=O
goto P1c

:B3o
If %b3% EQU X goto B2o
If %b3% EQU O goto B2o
set b3=O
goto P1c

:B2o
If %b2% EQU X goto B1o
If %b2% EQU O goto B1o
set b2=O
goto P1c

:B1o
If %b1% EQU X goto error1
If %b1% EQU O goto error1
set b1=O
goto P1c



:C5o
If %c5% EQU X goto C4o
If %c5% EQU O goto C4o
set c5=O
goto P1c

:C4o
If %c4% EQU X goto C3o
If %c4% EQU O goto C3o
set c4=O
goto P1c

:C3o
If %c3% EQU X goto C2o
If %c3% EQU O goto C2o
set c3=O
goto P1c

:C2o
If %c2% EQU X goto C1o
If %c2% EQU O goto C1o
set c2=O
goto P1c

:C1o
If %c1% EQU X goto error1
If %c1% EQU O goto error1
set c1=O
goto P1c


:D5o
If %d5% EQU X goto D4o
If %d5% EQU O goto D4o
set d5=O
goto P1c

:D4o
If %d4% EQU X goto D3o
If %d4% EQU O goto D3o
set d4=O
goto P1c

:D3o
If %d3% EQU X goto D2o
If %d3% EQU O goto D2o
set d3=O
goto P1c

:D2o
If %d2% EQU X goto D1o
If %d2% EQU O goto D1o
set d2=O
goto P1c

:D1o
If %d1% EQU X goto error1
If %d1% EQU O goto error1
set d1=O
goto P1c


:E5o
If %e5% EQU X goto E4o
If %e5% EQU O goto E4o
set e5=O
goto P1c

:E4o
If %e4% EQU X goto E3o
If %e4% EQU O goto E3o
set e4=O
goto P1c

:E3o
If %e3% EQU X goto E2o
If %e3% EQU O goto E2o
set e3=O
goto P1c

:E2o
If %e2% EQU X goto E1o
If %e2% EQU O goto E1o
set e2=O
goto P1c

:E1o
If %e1% EQU X goto error1
If %e1% EQU O goto error1
set e1=O
goto P1c

:F5o
If %f5% EQU X goto F4o
If %f5% EQU O goto F4o
set f5=O
goto P1c

:F4o
If %f4% EQU X goto F3o
If %f4% EQU O goto F3o
set f4=O
goto P1c

:F3o
If %f3% EQU X goto F2o
If %f3% EQU O goto F2o
set f3=O
goto P1c

:F2o
If %f2% EQU X goto F1o
If %f2% EQU O goto F1o
set f2=O
goto P1c

:F1o
If %f1% EQU X goto error1
If %f1% EQU O goto error1
set f1=O
goto P1c



:error1
Echo.
Echo Invalid Entry, That Column is Full
Echo.
pause
goto map1

:error2
Echo.
Echo Invalid Entry, That Column is Full
Echo.
pause
goto map2



:winx
cls
color 0A
set /a scorex=%scorex%+1
Echo.
Echo.
Echo Congrats %xs%, because...
Echo.
Echo.
Echo **
Echo **** **** * ********* ** ** ** **** **
Echo **** **** ** ** ** ** **** **
Echo ******** ** ** ** ** ** ** * **
Echo ****** ********* ** ** ** ** ** * **
Echo ******** ** ** ** ** ** ** * **
Echo **** **** ** ************ ** ** * **
Echo **** **** ******** ************ ** ** ****
Echo.
Echo.
pause
goto ending

:wino
cls
Color 0C
set /a scoreo=%scoreo%+1
Echo.
Echo.
Echo Congrats %os%, because...
Echo.
Echo.
Echo **
Echo ************ * ********* ** ** ** **** **
Echo ************ ** ** ** ** **** **
Echo ** ** ** ** ** ** ** ** * **
Echo ** ** ********* ** ** ** ** ** * **
Echo ** ** ** ** ** ** ** ** * **
Echo ************ ** ************ ** ** * **
Echo ************ ******** ************ ** ** ****
Echo.
Echo.
pause
goto ending

:draw
cls
color 0E
set /a draw=%draw%+1
Echo.
Echo.
Echo Sorry %xs% and %os%, but it's a...
Echo.
Echo.
Echo ######
Echo ## #
Echo ## # #### ##### # #
Echo ## # # # # # # #
Echo ## # # # # # # #
Echo ###### # #### # #####
Echo.
Echo.
pause
goto ending

:ending
cls
color 0E
Echo.
Echo.
Echo Press 1 to Play Again
Echo Press 2 to Change Players
Echo Press 3 to Exit
Echo.
set /p v=
IF %v% EQU 1 goto start
IF %v% EQU 2 goto superstart
IF %v% EQU 3 goto close

:close