gemini-capsule/twopigs.txt

122 lines
3.0 KiB
Plaintext

REM --- PIG Dice
REM --- Created: 2022-04-01 by lettuce
REM --- for Tiny BASIC
REM --- COPYLEFT ALL RIGHTS WRONGED
REM --- Variable List
REM
REM A - aggression, max times the computer will roll
REM C - Computer's total
REM H - Current Hand total
REM I - For determining if player needs instructions
REM D - Current die roll
REM P - Player total
REM R - A random number returned by the Random Number Generator
REM Q - For determining if player would like to roll again
LET A=4
LET H=0
LET C=0
LET P=0
REM --- Initialise the random number seed
10 PRINT "ENTER A 4 DIGIT NUMBER:"
INPUT R
PRINT "DO YOU NEED INSTRUCTIONS? (0 NO, 1 YES)"
INPUT I
IF I=1 THEN GOSUB 250
REM --- START
PRINT "WHAT POINT TOTAL TO PLAY TO?"
INPUT W
15 PRINT "You play first: "
REM --- MAIN GAME LOOP
20 PRINT "YOUR CURRENT HAND IS ",H
PRINT "WOULD YOU LIKE TO ROLL? (0 NO, 1 YES)"
INPUT Q
30 IF Q=0 THEN GOTO 40
REM --- CHECK IF PLAYER BUSTED
GOSUB 200
PRINT "YOU ROLLED ",D
IF D=1 THEN GOTO 50
LET H=H+D
GOTO 20
REM --- COMPUTER'S TURN
40 REM FIRST ADD PLAYER'S HAND TOTAL TO PLAYER TOTAL
REM AND DISPLAY IT
LET P=P+H
REM RESET H
42 LET H=0
GOSUB 150
REM CHECK IF PLAYER WON
GOSUB 100
PRINT ""
PRINT "MY TURN"
LET A=4
45 GOSUB 200
PRINT "I ROLLED ",D
IF D=1 THEN GOTO 60
LET H=H+D
LET A=A-1
REM CHECKING TO SEE IF COMPUTER WILL STOP ROLLING
IF A<1 THEN GOTO 47
GOTO 45
47 GOSUB 130
PRINT "I'M ENDING MY TURN"
LET C=H+C
PRINT "MY CURRENT TOTAL IS ",C
PRINT ""
LET H=0
GOSUB 150
GOTO 20
REM --- PLAYER BUSTS
50 PRINT "XXXXXXXXXXX"
PRINT "YOU BUSTED!"
PRINT "XXXXXXXXXXX"
GOTO 42
REM --- COMPUTER BUSTS
60 PRINT "I BUSTED!"
PRINT "MY TOTAL IS ",C
LET H=0
GOSUB 150
GOTO 20
REM - CHECK IF PLAYER WINS
100 IF P>W THEN GOTO 120
RETURN
120 PRINT "CONGRATULATIONS, YOU WIN!"
GOTO 300
REM - CHECK IF COMPUTER WINS
130 IF C>W THEN GOTO 140
RETURN
140 PRINT "YOU LOSE!"
GOTO 300
REM PRINT PLAYER TOTAL
150 PRINT "YOUR CURRENT TOTAL IS ",P
RETURN
200 LET D=1+R-R/6*6
LET R=5*R+35
LET R=R-R/6547*6547
RETURN
REM INSTRUCTIONS
250 PRINT "Pig is a simple competitive dice game for two players. In a round, a player may roll a single die as many times as they want, each time adding the points to their hand for that round. They may stop at any time and add the hand to their total game points. If they roll a 1 at any time they are 'BUSTED'. They immediately stop and lose all accrued points in the hand for that round. When a player stops by choice or due to busting, the other player begins a new turn. Game continues in this fashion ending when either player reaches a previously agreed-upon point total."
PRINT ""
RETURN
REM END
300 PRINT "YOUR SCORE IS ",P
PRINT "COMPUTER SCORE IS ",C
PRINT "GOODBYE"