The   game of Pig   is a multiplayer game played with a single six-sided die.   The
object of the game is to reach   100   points or more.  
Play is taken in turns.   On each person's turn that person has the option of either:

 Rolling the dice:   where a roll of two to six is added to their score for that turn and the player's turn continues as the player is given the same choice again;   or a roll of   1   loses the player's total points   for that turn   and their turn finishes with play passing to the next player.
 Holding:   the player's score for that round is added to their total and becomes safe from the effects of throwing a   1   (one).   The player's turn finishes with play passing to the next player.


Task

Create a program to score for, and simulate dice throws for, a two-person game.



Related task

   Pig the dice game/Player


100 PROGRAM "Pig.bas"
110 RANDOMIZE 
120 STRING PLAYER$(1 TO 2)*28
130 NUMERIC POINTS(1 TO 2),VICTORY(1 TO 2)
140 LET WINNINGSCORE=100
150 TEXT 40:PRINT "Let's play Pig!";CHR$(241):PRINT 
160 FOR I=1 TO 2
170   PRINT "Player";I
180   INPUT PROMPT "Whats your name? ":PLAYER$(I)
190   LET POINTS(I)=0:LET VICTORY(I)=0:PRINT 
200 NEXT
210 DO
220   CALL TAKETURN(1)
230   IF NOT VICTORY(1) THEN CALL TAKETURN(2)
240 LOOP UNTIL VICTORY(1) OR VICTORY(2)
250 IF VICTORY(1) THEN
260   CALL CONGRAT(1)
270 ELSE
280   CALL CONGRAT(2)
290 END IF
300 DEF TAKETURN(P)
310   LET NEWPOINTS=0
320   SET #102:INK 3:PRINT :PRINT "It's your turn, " PLAYER$(P);"!":PRINT "So far, you have";POINTS(P);"points in all."
330   SET #102:INK 1:PRINT "Do you want to roll the die? (y/n)"
340   LET KEY$=ANSWER$
350   DO WHILE KEY$="y"
360     LET ROLL=RND(6)+1
370     IF ROLL=1 THEN
380       LET NEWPOINTS=0:LET KEY$="n"
390       PRINT "Oh no! You rolled a 1! No new points after all."
400     ELSE
410       LET NEWPOINTS=NEWPOINTS+ROLL
420       PRINT "You rolled a";ROLL:PRINT "That makes";NEWPOINTS;"new points so far."
430       PRINT "Roll again? (y/n)"
440       LET KEY$=ANSWER$
450     END IF
460   LOOP
470   IF NEWPOINTS=0 THEN
480     PRINT PLAYER$(P);" still has";POINTS(P);"points."
490   ELSE
500     LET POINTS(P)=POINTS(P)+NEWPOINTS:LET VICTORY(P)=POINTS(P)>=WINNINGSCORE
510   END IF
520 END DEF
530 DEF CONGRAT(P)
540   SET #102:INK 3:PRINT :PRINT "Congratulations ";PLAYER$(P);"!"
550   PRINT "You won with";POINTS(P);"points.":SET #102:INK 1
560 END DEF
570 DEF ANSWER$
580   LET K$=""
590   DO
600     LET K$=LCASE$(INKEY$)
610   LOOP UNTIL K$="y" OR K$="n"
620   LET ANSWER$=K$
630 END DEF