Skip to content

Instantly share code, notes, and snippets.

@do0m-nametaken
Created January 28, 2021 06:54
Show Gist options
  • Save do0m-nametaken/1d292a7db468e1d41467fd959d0f6e19 to your computer and use it in GitHub Desktop.
Save do0m-nametaken/1d292a7db468e1d41467fd959d0f6e19 to your computer and use it in GitHub Desktop.
Batch RPS ASCII - Rock Paper Scissors in Batch
:: Batch RPS ASCII by Sean
:: RPS ASCII art from https://gist.github.com/wynand1004/b5c521ea8392e9c6bfe101b025c39abe by Christian Thompson or "wynand1004"
@echo off
title Rock Paper Scissors
set notrandomperm=0
set "ping=%systemroot%\system32\ping.exe"
set "choice=%systemroot%\system32\choice.exe"
if not exist "%ping%" set _nocmd=ping & goto:nosup
if not exist "%choice%" set _nocmd=choice & goto:nosup
:: If this script is run with a parameter of either 1 or 0,
:: ==========================================================
:: = Examples: =
:: = 1. Running this script with the call command in cmd =
:: = call rps 1<--(1 is the parameter) =
:: = =
:: = 2. File link to this script with a parameter =
:: = Link Shortcut: "(Directory to script)\rps.bat" 1 =
:: ==========================================================
::
:: The script will detect the parameter and use it to set the "ifnotrandom" variable
:: (Refer to the comments below)
set "ifgivennotrandom=%1"
if not defined ifgivennotrandom goto:start
if defined ifgivennotrandom (
if %ifgivennotrandom%==1 set ifnotrandom=1
if %ifgivennotrandom%==0 set ifnotrandom=0
)
setlocal
goto:start
:nosup
cls
echo You unfortunately do not support the %_nocmd%command
echo Which this script uses
echo So you can't use this script :(
echo.
echo Press any key to exit...
pause>nul
exit
:start
:: If "ifnotrandom" is set to 1 then let players choose RPS
:: If "ifnotrandom" is set to 0 then all choices are random
if not defined ifnotrandom goto:chooseifnotrandom
if defined ifnotrandom (
if %ifnotrandom%==1 goto:choose
if %ifnotrandom%==0 goto:random
)
:chooseifnotrandom
cls
echo Random Choice [Press R] or Let player choose [Press C]?
choice /c RC /n
if %ERRORLEVEL% equ 1 set ifnotrandom=0
if %ERRORLEVEL% equ 2 set ifnotrandom=1
if %ifnotrandom%==1 goto:choose
if %ifnotrandom%==0 goto:random
:random
set ifchoose=0
goto:gotime
:choose
set ifchoose=1
if not defined cp1use set ifplayer1set=
if not defined cp2use set ifplayer2set=
if defined cp1use set ifplayer1set=READY!
if defined cp2use set ifplayer2set=READY!
cls
echo You sadly cannot choose at the same time
echo.
echo Player 1=%ifplayer1set%
echo Player 2=%ifplayer2set%
echo.
echo For Player 1:
echo Press 1,2,3,4 for Rock, Paper, Scissors, or Random
echo.
echo For Player 2:
echo Press 7,8,9,0 for Rock, Paper, Scissors, or Random
if defined cp1use if defined cp2use ping localhost -n 1 -w 1 >nul & goto:gotime
choice /c 12347890 /n >nul
if %ERRORLEVEL% equ 1 set cp1use=1
if %ERRORLEVEL% equ 2 set cp1use=3001
if %ERRORLEVEL% equ 3 set cp1use=6001
if %ERRORLEVEL% equ 4 set /a "cp1use="(%RANDOM%*9000/32768)+1"
if %ERRORLEVEL% equ 5 set cp2use=1
if %ERRORLEVEL% equ 6 set cp2use=3001
if %ERRORLEVEL% equ 7 set cp2use=6001
if %ERRORLEVEL% equ 8 set /a "cp2use="(%RANDOM%*9000/32768)+1"
goto:choose
:gotime
for /l %%v in (1,1,2) do (for /l %%d in (1,1,6) do (set "p%%vuse=" & set "p%%v_line%%d=" ))
if %ifchoose% equ 0 set /a "p1use="(%RANDOM%*9000/32768)+1"
if %ifchoose% equ 0 set /a "p2use="(%RANDOM%*9000/32768)+1"
if %ifchoose% equ 1 set "p1use=%cp1use%"
if %ifchoose% equ 1 set "p2use=%cp2use%"
if %p1use% lss 3001 (
set "p1_line1= _______ "
set "p1_line2=---' ____) "
set "p1_line3= (_____) "
set "p1_line4= (_____) "
set "p1_line5= (____) "
set "p1_line6=---.__(___) "
set p1_use=1
)
if %p1use% gtr 3000 if %p1use% lss 6001 (
set "p1_line1= ________ "
set "p1_line2=---' ____)____ "
set "p1_line3= ______)"
set "p1_line4= ______)"
set "p1_line5= _______) "
set "p1_line6=---.__________) "
set p1_use=2
)
if %p1use% gtr 6000 if %p1use% lss 9001 (
set "p1_line1= ________ "
set "p1_line2=---' ____)____ "
set "p1_line3= ______)"
set "p1_line4= __________)"
set "p1_line5= (____) "
set "p1_line6=---.__(___) "
set p1_use=3
)
if %p2use% lss 3001 (
set "p2_line1= _______ "
set "p2_line2= (____ '---"
set "p2_line3= (_____) "
set "p2_line4= (_____) "
set "p2_line5= (____) "
set "p2_line6= (___)__.---"
set p2_use=1
)
if %p2use% gtr 3000 if %p2use% lss 6001 (
set "p2_line1= ________ "
set "p2_line2= ____(____ '---"
set "p2_line3=(______ "
set "p2_line4=(_______ "
set "p2_line5= (_______ "
set "p2_line6= (__________.---"
set p2_use=2
)
if %p2use% gtr 6000 if %p2use% lss 9001 (
set "p2_line1= _______ "
set "p2_line2= _____(____ '---"
set "p2_line3=(_______ "
set "p2_line4=(__________ "
set "p2_line5= (____) "
set "p2_line6= (___)__.---"
set p2_use=3
)
set "p1_ifwin= "
set "p2_ifwin= "
set "iftie= "
if %p1_use% equ 1 if %p2_use% equ 3 set "p1_ifwin=WINNER!" & set "winner=1"
if %p1_use% equ 2 if %p2_use% equ 1 set "p1_ifwin=WINNER!" & set "winner=1"
if %p1_use% equ 3 if %p2_use% equ 2 set "p1_ifwin=WINNER!" & set "winner=1"
if %p1_use% equ %p2_use% set "iftie=TIE!" & set "winner=3"
if %p2_use% equ 1 if %p1_use% equ 3 set "p2_ifwin=WINNER!" & set "winner=2"
if %p2_use% equ 2 if %p1_use% equ 1 set "p2_ifwin=WINNER!" & set "winner=2"
if %p2_use% equ 3 if %p1_use% equ 2 set "p2_ifwin=WINNER!" & set "winner=2"
cls
echo.
echo _______ _______
echo ---' ____) (____ '---
echo (_____) (_____)
echo (_____) (_____)
echo (____) (____)
echo ---.__(___) (___)__.---
echo.
echo """) ("""
echo.
ping localhost -n 1 -w 1 >nul
cls
echo.
echo.
echo _______ _______
echo ---' ____) (____ '---
echo (_____) (_____)
echo (_____) (_____)
echo (____) (____)
echo ---.__(___) (___)__.---
echo """) ("""
echo.
echo Rock,
ping localhost -n 1 -w 1 >nul
cls
echo.
echo _______ _______
echo ---' ____) (____ '---
echo (_____) (_____)
echo (_____) (_____)
echo (____) (____)
echo ---.__(___) (___)__.---
echo.
echo """) ("""
echo.
echo Rock,
ping localhost -n 1 -w 1 >nul
cls
echo.
echo.
echo _______ _______
echo ---' ____) (____ '---
echo (_____) (_____)
echo (_____) (_____)
echo (____) (____)
echo ---.__(___) (___)__.---
echo """) ("""
echo.
echo Rock, Paper,
ping localhost -n 1 -w 1 >nul
cls
echo.
echo _______ _______
echo ---' ____) (____ '---
echo (_____) (_____)
echo (_____) (_____)
echo (____) (____)
echo ---.__(___) (___)__.---
echo.
echo """) ("""
echo.
echo Rock, Paper,
ping localhost -n 1 -w 1 >nul
cls
echo.
echo %p1_ifwin% %iftie% %p2_ifwin%
echo %p1_line1% %p2_line1%
echo %p1_line2% %p2_line2%
echo %p1_line3% %p2_line3%
echo %p1_line4% %p2_line4%
echo %p1_line5% %p2_line5%
echo %p1_line6% %p2_line6%
echo """) ("""
echo.
echo Rock, Paper, Scissors!
echo.
if %winner% equ 1 echo Player 1 is the winner!
if %winner% equ 2 echo Player 2 is the winner!
if %winner% equ 3 echo TIE!
echo.
if defined cp1use set cp1use=
if defined cp2use set cp2use=
echo Press any key to try again...
pause>nul
goto:start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment