Problem 45967. Backgammon #1 - Pip Count
The following is a possible representation of a backgammon board:
- White stones are represented by positive integers Red stones represented by negative integers.
- The board is a vector of integers: The first 24 integers are the points numbered (from White's perspective) 1 to 24; integers 25 and 26 are white's bar and red's bar respectively; integers 27 and 28 are whites home and red's home respectively
- Each integer represents the number of stones on that point; e.g. 4 means white has 4 stones on that point; -2 means red has 2 stones on that point.
So initial board set-up is (from White's perspective):
Which is represented as:
White moves towards point 1, red towards point 24.
The Pip Count rates the relative strength of one player's position against the other's, by counting the total dice throw required to exactly bear off all that player's remaining stones and comparing the relative count of one player against the other to determine which has the stronger position.
The input is a vector describing a backgammon board position using the above notation. You should return a vector containing three elements: white's pip count, red's pipcount and the relative pipcount from white's perspective - i.e. a negative relative pipcount means that white has the stronger position.
Before attempting to calculate the pipcount you should check that the input represents a legal backgammon board position. If it doesn't then you should return NaN for all three output elements.
Next problem in series: Problem 46006. Backgammon #2 - Your turn!
Regexp cheats and other cheats are not appreciated and will be blocked if you use them.
Solution CommentsShow comments
Problem Recent Solvers3