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


require'general/misc/prompt' NB. was require'misc' in j6
 
status=:3 :0
  'pid cur tot'=. y
   player=. 'player ',":pid
   potential=. ' potential: ',":cur
   total=. ' total: ',":tot
  smoutput player,potential,total
)
 
getmove=:3 :0
  whilst.1~:+/choice do.
    choice=.'HRQ' e. prompt '..Roll the dice or Hold or Quit? [R or H or Q]: '
  end.
  choice#'HRQ'
) 
 
NB. simulate an y player game of pig
pigsim=:3 :0
  smoutput (":y),' player game of pig'
  scores=.y#0
  while.100>>./scores do.
    for_player.=i.y do.
      smoutput 'begining of turn for player ',":pid=.1+I.player
      current=. 0
      whilst. (1 ~: roll) *. 'R' = move do.
        status pid, current, player+/ .*scores
        if.'R'=move=. getmove'' do.
          smoutput 'rolled a ',":roll=. 1+?6
          current=. (1~:roll)*current+roll end. end.
      scores=. scores+(current*player)+100*('Q'e.move)*-.player
      smoutput 'player scores now: ',":scores end. end.
  smoutput 'player ',(":1+I.scores>:100),' wins'
)