Jump to content

Rock, Paper, Scissors anyone ?


Recommended Posts

Posted
Ever wondered if you could make a Rock, Paper, Scissors game in Batch? Well, its possible...


Ok, After a suggestion by my girl I made this, it  isn't the best code. It's five minutes of work but I thought I'd share my pointless exercise with the community. Enjoy I hope you have hours of fun playing!

@ECHO off

set wins=0
set loss=0
set draws=0

:start
CLS
ECHO.
ECHO.
ECHO -------------------------------------------------------------------------------
ECHO.
ECHO                           Rock, Paper, Scissors
ECHO                                                                      By GonZor
ECHO -------------------------------------------------------------------------------
ECHO Wins: %wins%  Losses: %loss%  Draws: %draws%
ECHO -------------------------------------------------------------------------------
ECHO.

SET choice=
SET RndNum=%time:~10,1%
IF '%RndNum%' == '0' SET comp=1
IF '%RndNum%' == '1' SET comp=2
IF '%RndNum%' == '2' SET comp=3
IF '%RndNum%' == '3' SET comp=1
IF '%RndNum%' == '4' SET comp=2
IF '%RndNum%' == '5' SET comp=3
IF '%RndNum%' == '6' SET comp=1
IF '%RndNum%' == '7' SET comp=2
IF '%RndNum%' == '8' SET comp=3
IF '%RndNum%' == '9' SET comp=1

ECHO 1. Rock
ECHO 2. Paper
ECHO 3. Scissors
ECHO.

SET /p choice="startect Rock, Paper or Scissors: "

IF '%choice%' == '1' GOTO rock
IF '%choice%' == '2' GOTO paper
IF '%choice%' == '3' GOTO scissors
IF '%choice%' == '666' (
    GOTO cool
) ELSE (
    GOTO start
)

:rock

IF '%comp%' == '1' GOTO draw
IF '%comp%' == '2' GOTO lose
GOTO win

:paper

IF '%comp%' == '2' GOTO draw
IF '%comp%' == '3' GOTO lose
GOTO win

:scissors

IF '%comp%' == '3' GOTO draw
IF '%comp%' == '1' GOTO lose
GOTO win

:lose
SET /a loss=%loss% + 1
CLS
ECHO.
ECHO.
ECHO -------------------------------------------------------------------------------
ECHO.
ECHO                                   YOU LOSE!
ECHO.
ECHO -------------------------------------------------------------------------------
PAUSE
GOTO start

:win
SET /a wins=%wins% + 1
CLS
ECHO.
ECHO.
ECHO -------------------------------------------------------------------------------
ECHO.
ECHO                                    YOU WIN!
ECHO.
ECHO -------------------------------------------------------------------------------
PAUSE
GOTO start

:draw
SET /a draws=%draws% + 1
CLS
ECHO.
ECHO.
ECHO -------------------------------------------------------------------------------
ECHO.
ECHO                                      DRAW!
ECHO.
ECHO -------------------------------------------------------------------------------
PAUSE
GOTO start

:cool
SET /a wins=%wins% + 666
CLS
ECHO.
ECHO.
ECHO -------------------------------------------------------------------------------
ECHO.
ECHO                                  YOU'RE AWESOME!!
ECHO.
ECHO -------------------------------------------------------------------------------
PAUSE
GOTO start


[me=GonZor]got bored  :-([/me]

And about the '666', she wanted a cheat :P

EDIT - Just added a wins/losses/draws summary. Thanks to Marcs request.

Posted

If anyone is wondering, this is why he hasn't released anything in a while... we've been developing this amazing rock paper scissors game for months now.  :-P

Posted
If anyone is wondering, this is why he hasn't released anything in a while... we've been developing this amazing rock paper scissors game for months now.  :-P

lol  :lol:

Posted

Decided to give it a try in VB6:

http://www.twistedpairrecords.com/digip/Ro...er_Scissors.rar

All soucrce code to VB6 project plus exe in rar file.

Edit: Fixed bug. Gave a loss when it was actually a win.

Dam, its much prettier! Nice work! One question, where's the cheat? :P

Well, I didn't want some user key combo, etc, type cheat. There are a few lines in there commented out that when in place, will allow you the pc to guess a 0 or 4 which = forfeit for the game. In otherwords, it ups your chances of winning, but you can add something, like  a key combo of "ctrl+alt+whatever" = a win, or if you enabled a little text box and button that appeard on certain key combo and type god and submit it gives you 777 wins, etc, but I personally didn't add an easy cheat methods.

Posted

Decided to give it a try in VB6:

http://www.twistedpairrecords.com/digip/Ro...er_Scissors.rar

All soucrce code to VB6 project plus exe in rar file.

Edit: Fixed bug. Gave a loss when it was actually a win.

Dam, its much prettier! Nice work! One question, where's the cheat? :P

Well, I didn't want some user key combo, etc, type cheat. There are a few lines in there commented out that when in place, will allow you the pc to guess a 0 or 4 which = forfeit for the game. In otherwords, it ups your chances of winning, but you can add something, like  a key combo of "ctrl+alt+whatever" = a win, or if you enabled a little text box and button that appeard on ceartain key combo and type god and submit it gives you 777 wins, etc, but I personally didn't add an easy cheat methods.

in the command version type 666  :lol:

Posted

I chose 777 in light of the "GOD" button, but you could set it to anything.

Posted

That is some of the finest batch script i have ever seen!  :D Bravo

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...