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


// Pig the Dice for two players.
Player = {}
Player.score = 0
Player.doTurn = function()
    rolls = 0
    pot = 0
    print self.name + "'s Turn!"
    while true
        if self.score + pot >= goal then
            print "   " + self.name.upper + " WINS WITH " + (self.score + pot) + "!"
            inp = "H"
        else
            inp = input(self.name + ", you have " + pot + " in the pot.  [R]oll or Hold? ")
        end if
        if inp == "" or inp[0].upper == "R" then
            die = ceil(rnd*6)
            if die == 1 then
                print "   You roll a 1.  Busted!"
                return
            else
                print "   You roll a " + die + "."
                pot = pot + die
            end if
        else
            self.score = self.score + pot
            return
        end if
    end while
end function
 
p1 = new Player
p1.name = "Alice"
p2 = new Player
p2.name = "Bob"
goal = 100
 
while p1.score < goal and p2.score < goal
    for player in [p1, p2]
        print
        print p1.name + ": " + p1.score + "  |  " + p2.name + ": " + p2.score
        player.doTurn
        if player.score >= goal then break
    end for
end while