Rock Paper Scissors Game With CMD

by RayOkay in Circuits > Software

74 Views, 1 Favorites, 0 Comments

Rock Paper Scissors Game With CMD

F5LYDJ9LYQN618V.png

Play Rock Paper Scissors in Windows Command Prompt!

Supplies


A Windows PC

Notepad

Command Prompt

Knowledge Of How To Turn .txt Files Into .bat Files

THE CODE

images.jpg

Copy the code between the hashtags, and save it as a .bat file.

###################################################



@echo off
cls
set "plscore=0"
set "aiscore=0"
set /a "pingtime=%random% * (7 - 1) / 32768 + 1"
color 0e
cls
title Rock Paper Scissors (2.0)
echo Welcome To Rock Paper Scissors!
ping -n 2 127.0.0.1>null
echo This Game Was Made By Rayden (Nickname: RayOkay)
ping -n 2 127.0.0.1>null
echo Hopefully multiplayer will be added in the next update though...
ping -n 2 127.0.0.1>null
echo So now you'll just be playing with a computer!
ping -n 2 127.0.0.1>null
:NAME
cls
echo Enter your name: (Must Be One Word Long)
set/p "username=>"
if %username%==Computer goto BADNAME
echo Well hi, %username%!
echo Starting match... (Please Wait And Do Not Press Any Keys)
ping -n %pingtime% 127.0.0.1>nul
goto GAME
:GAME
cls
set /a "aiattacknum=%random% * (4 - 1) / 32768 + 1"
if %aiattacknum%==1 set "aiattack=ROCK"
if %aiattacknum%==2 set "aiattack=PAPER"
if %aiattacknum%==3 set "aiattack=SCISSORS"
echo Computer Chosen
:ATTACK
echo %username%'s Choice (Please type R/P/S in CAPTIAL)
set /p "plattack=>"
if %plattack%==R goto ROCK
if %plattack%==P goto PAPER
if %plattack%==S goto CUT
echo Invalid Choice!
goto GAME
:ROCK
set "plattacknum=1"
if %aiattacknum%==2 goto AI2PL1
if %aiattacknum%==1 goto AI1PL1
echo Computer Chose %aiattack%!
echo %username% Chose ROCK!
echo %username% Won!
set /a "plscore=plscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:PAPER
set "plattacknum=2"
if %aiattacknum%==3 goto AI3PL2
if %aiattacknum%==2 goto AI2PL2
echo Computer Chose %aiattack%!
echo %username% Chose PAPER!
echo %username% Won!
set /a "plscore=plscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:CUT
set "platttacknum=3"
if %aiattacknum%==1 goto AI1PL3
if %aiattacknum%==3 goto AI3PL3
echo Computer Chose %aiattack%!
echo %username% Chose SCISSORS!
echo %username% Won!
set /a "plscore=plscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI2PL1
echo Computer Chose %aiattack%!
echo %username% Chose ROCK!
echo %username% Lost!
set /a "aiscore=aiscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI1PL1
echo Computer Chose %aiattack%!
echo %username% Chose ROCK!
echo Tie!
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI3PL2
echo Computer Chose %aiattack%!
echo %username% Chose PAPER!
echo %username% Lost!
set /a "aiscore=aiscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI2PL2
echo Computer Chose %aiattack%!
echo %username% Chose PAPER!
echo Tie!
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI1PL3
echo Computer Chose %aiattack%!
echo %username% Chose SCISSORS!
echo %username% Lost!
set /a "aiscore=aiscore+1"
echo Computer Score: %aiscore% %username%'s Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:AI3PL3
echo Computer Chose %aiattack%!
echo %username% Chose SCISSORS!
echo Tie!
echo Computer Score: %aiscore% Your Score: %plscore%
pause> nul | set /p "=Next One? (Press Any Key)"
goto GAME
:BADNAME
echo Invalid Name!
goto NAME



##################################

Credit

Credit to NotePro for the random variable controller