000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. RPCGAMRB.
000300 AUTHOR.  Ryan Brooks.
000400* ASK USED FOR ROCK, PAPER OR SCISSORS.
000500* COMPARE THEIR INPUT ANSSWER TO THE RANDOM NUMBER
000600* GENERATED BY THE PROGRAM.  PROVIDE WINNER/LOSER FEEDBACK. 
000700 
000800 DATA DIVISION.
000900 WORKING-STORAGE SECTION.
001000  
001100 01  WS-TODAYS-DATE          pic x(08).
001200 01  WS-TIME.
001300     05 WS-TIME-HH           pic 9(02).
001400     05 WS-TIME-MM           PIC 9(02).
001500     05 WS-TIME-SS           PIC 9(02).
001600     05 WS-TIME-MS.
001700        10 WS-TIME-MS1       PIC 9(01).
001800        10 WS-TIME-MS2       PIC 9(01).
001900           88 RANDOM-ROCK              VALUE 0 1 2.     
002000           88 RANDOM-PAPER             VALUE 3 4 5.
002100           88 RANDOM-SCISSORS          VALUE 6 7 8.
002200           88 VALID-RANDOM-DIGIT       VALUE 0 THRU 8.
002300              
002400 01 WS-CHOICE                PIC X(01).
002500    88 ROCK-CHOSEN                     VALUE 'R' 'r'.
002600    88 PAPER-CHOSEN                    VALUE 'P' 'p'.
002700    88 SCISSORS-CHOSEN                 VALUE 'S' 's'.
002800    88 VALID-CHOICE                    VALUE 'R' 'r'
002900                                             'P' 'p'
003000                                             'S' 's'.
003100 01 ANY-KEY                  PIC X(01).
003200 PROCEDURE DIVISION.
003300 0000-MAINLINE.
003400     DISPLAY 'START RPSGAMRB BY RYAN BROOKS'.
003500     ACCEPT WS-TODAYS-DATE from date yyyymmdd.
003600     DISPLAY "PROGRAM EXECUTION DATE      : " WS-TODAYS-DATE.
003700     ACCEPT WS-TIME from time.
003800     DISPLAY "PROGRAM EXECUTION START TIME: " WS-TIME.
003900  
004000* PROMPT THE USER FOR GAME CHOICE UNTIL A VALID CHOICE IS MADE. 
004100     PERFORM UNTIL VALID-CHOICE
004200       DISPLAY "R FOR ROCK, P FOR PAPER, S FOR SCISSORS"
004300       ACCEPT WS-CHOICE
004400     END-PERFORM
004500     
004600* DISPLAY THE USERS CHOICE HERE WITH IF STATEMENTS.
004700* (YOU ADD THIS CODE):
004800  EVALUATE WS-CHOICE  
004900      WHEN "R"
005000         DISPLAY "YOU CHOSE ROCK, SOLID CHOICE."
005100     WHEN "P"
005200         DISPLAY "YOU CHOSE PAPER, YOU HAVE THIS COVERED."
005300     WHEN "S"
005400         DISPLAY "YOU CHOSE SCISSORS, HOPE IT'S NOT A ROCK."
005500     WHEN "r"
005600         DISPLAY "YOU CHOSE ROCK, SOLID CHOICE."
005700     WHEN "p"
005800         DISPLAY "YOU CHOSE PAPER, YOU HAVE THIS COVERED."
005900     WHEN "s"
006000         DISPLAY "YOU CHOSE SCISSORS, HOPE IT'S NOT A ROCK."
006100  END-EVALUATE
006200  
006300* QUASI-RANDOM NUMBER GENERATOR FOR GAME    
006400     MOVE 9 TO WS-TIME-MS2.
006500     PERFORM UNTIL VALID-RANDOM-DIGIT
006600       ACCEPT WS-TIME from time
006700     END-PERFORM  
006800     display "--------------------------"
006900     display "TIME DIGIT: " WS-TIME-MS2
007000     
007100* WRITE CODE IF / EVALUATE TO DISPLAY THE COMPUTER CHOICE.
007200* (YOU ADD THIS CODE):
007300 evaluate true
007400    when RANDOM-ROCK and ROCK-CHOSEN
007500         display "The computer chooses rock."
007600         display "--------------------------"
007700         display "Tie!"
007800     when RANDOM-ROCK and PAPER-CHOSEN
007900         display "The computer chooses rock."
008000         display "--------------------------"
008100         DISPLAY "Paper wins equals you win."
008200     when RANDOM-ROCK and SCISSORS-CHOSEN
008300         display "The computer chooses rock."
008400         display "--------------------------"
008500         DISPLAY "Rock crushes scissors, computer wins."
008600     when RANDOM-PAPER AND ROCK-CHOSEN
008700         display "The computer chooses paper."
008800         display "--------------------------"
008900         DISPLAY "Paper beats rock, computer wins."
009000     when RANDOM-PAPER and PAPER-CHOSEN
009100         display "The computer chooses paper."
009200         display "--------------------------"
009300         DISPLAY "Tie!"
009400     WHEN RANDOM-PAPER and SCISSORS-CHOSEN
009500         display "The computer chooses paper."
009600         display "--------------------------"
009700         DISPLAY "Scissors win, paper loses; player wins."
009800     when RANDOM-SCISSORS and ROCK-CHOSEN
009900         display "The computer chooses scissors."
010000         display "--------------------------"
010100         DISPLAY "You win, you crushed the scissors."
010200     when RANDOM-SCISSORS and PAPER-CHOSEN
010300         display "The computer chooses scissors."
010400         display "--------------------------"
010500         DISPLAY "Scissors cuts paper, computer wins."
010600     WHEN RANDOM-SCISSORS and SCISSORS-CHOSEN
010700         display "The computer chooses scissors."
010800         display "--------------------------"
010900         DISPLAY "Tie!"
011000 END-EVALUATE.    
011100* COMPARE THE USER INPUT TO THE RANDOM CHOICE
011200* RULES OF THE GAME ARE:
011300*   PAPER COVERS ROCK - PAPER WINS ROCK LOSES 
011400*   ROCK CRUSHES SCISSORS - ROCK WINS, SCISSORS LOSES
011500*   SCISSORS CUTS PAPER - SCISSORS WIN, PAPER LOSES
011600* USE THE EVALUTE TO DECLARE THE RESULTS.
011700* (YOU CODE THIS)
011800     display "Press any key to exit."
011900        accept any-key.
012000     GOBACK.