Pig the dice game/Player

You are encouraged to solve this task according to the task description, using any language you may know.
Task

Create a dice simulator and scorer of Pig the dice game and add to it the ability to play the game to at least one strategy.

 State here the play strategies involved.
 Show play during a game here.


As a stretch goal:

 Simulate playing the game a number of times with two players of given strategies and report here summary statistics such as, but not restricted to, the influence of going first or which strategy seems stronger.


Game Rules

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 one. The player's turn finishes with play passing to the next player.


References
 Pig (dice)
 The Math of Being a Pig and Pigs (extra) - Numberphile videos featuring Ben Sparks.


with javascript_semantics
constant maxScore = 100
 
function one_game(sequence strategies)
    integer numPlayers = length(strategies),
            points = 0, -- points accumulated in current turn, 0=swap turn
            rolls  = 0, -- number of rolls
            player = rand(numPlayers)   -- start with a random player
    sequence scores = repeat(0,numPlayers)
    while true do
        integer roll = rand(6)
        if roll=1 then
            points = 0 -- swap turn
        else            
            points += roll
            if scores[player]+points>=maxScore then exit end if
            rolls += 1
            integer play = strategies[player]
            if not play(scores,player,points,rolls) then
                scores[player] += points
                points = 0 -- swap turn
            end if
        end if
        if points=0 then
            player = mod(player,numPlayers) + 1
            rolls = 0
        end if
    end while
    return player
end function
 
-- each strategy returns true to roll, false to hold.
 
function strategy1(sequence /*scores*/, integer /*player*/, points, /*rolls*/)
    return points<20    -- roll until 20 or more
end function
 
function strategy2(sequence /*scores*/, integer /*player*/, /*points*/, rolls)
    return rolls<4      -- roll 4 times
end function
 
function strategy3(sequence scores, integer player, points, /*rolls*/)
    -- roll until 20 or score>80
    return points<20 or scores[player]+points>80
end function
 
function strategy4(sequence scores, integer player, points, /*rolls*/)
    -- roll until 20 or any player has >71
    for i=1 to length(scores) do
        if scores[i]>71 then return true end if
    end for
    return points<20
end function
 
constant strategies = {strategy1,strategy2,strategy3,strategy4},
         numStrategies = length(strategies), 
         numOpponents = numStrategies-1
 
-- play each strategy 1000 times against all combinations of other strategies
for s=1 to numStrategies do
    integer strategy = strategies[s],
            mask = power(2,numOpponents)-1,
            wins = 0
    sequence opponents = deep_copy(strategies)
             opponents[s..s] = {} -- (ie all others only)
    for m=1 to mask do -- (all possible bit settings, bar 0, eg/ie 1..7)
        sequence game = {strategy}
        for g=1 to numOpponents do
            if and_bits(m,power(2,g-1)) then
                game &= opponents[g]
            end if
        end for
        for n=1 to 1000 do
            wins += one_game(game)=1
        end for
    end for
    printf(1,"strategy %d: %d wins\n",{s,wins}) 
end for
