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


import rand
import rand.seed
import os
fn main() {
	rand.seed(seed.time_seed_array(2)) //Set seed to current time
 
	mut player_scores := [0, 0]
	mut turn := 0
	mut current_score := 0
 
	for {
		player := turn % player_scores.len
 
		answer := os.input("Player $player [${player_scores[player]}, $current_score], (H)old, (R)oll or (Q)uit: ").to_lower()
 
		match answer {
            "h"{ //Hold
                player_scores[player] += current_score
                print("    Player $player now has a score of ${player_scores[player]}.\n")
 
                if player_scores[player] >= 100 {
                    println("    Player $player wins!!!")
                    return
                }
 
                current_score = 0
                turn += 1
            }
            "r"{ //Roll
                roll := rand.int_in_range(1, 7) or {1}
 
                if roll == 1 {
                    println("    Rolled a 1. Bust!\n")
                    current_score = 0
                    turn += 1
                } else {
                    println("    Rolled a ${roll}.")
                    current_score += roll
                }
            }
            "q"{ //Quit
                return
            }
            else{ //Incorrent input
                println("  Please enter one of the given inputs.")
            }
		}
	}
	println("Player ${(turn-1)%player_scores.len} wins!!!", )
}