how to check legality.
you have your 1D array representing the board, with array indices that represent the sequential position. 1-24 for each point, plus 0 and 25 for the bar would be how i structure it.
each color moves a certain direction, so the rolls of the dice will determine what the allowable moves are.
say white starts at point 1 and moves towards point 24. say youve got your intial pieces at setup, on points 1, 12, 17, and 19. you roll a 5 and a 6 on the dice.
white indicates that he wants to move pieces from point 1. therefore "Possible" moves could be from that point, to point 1+5 = 6, to point 1+6=7, and to point 1+11=12.
check the "possible" moves to see if other pieces are there: point #6 has more than one of the opponent's pieces, therefore not valid. point #7 is empty, therefore it is valid. point #12 has their own pieces on it, and could be valid, but there are 5 pieces there so its full and is in fact not a valid move.
to consider moves from the "bar" for white, i would consider that location 0, for black i would say location 25.
you can have several possible move results for any piece.
1- allowable, no attack. just increases the number of pieces at that point.
2 - allowable, attack. one opponent piece is alone, and will be knocked off to it's bar location.
3 - not allowable, opponent owns point. 2 or more opponent pieces block that point.
3 - not allowable, side full. 5 of your pieces are already there.
4 - "bearing off". piece is moved off the board. this is only allowed when all of the pieces are in the "home board" (the last 6 points)
each roll must be moved by a piece, if possible. two peices can move one die each, or one piece can combine both dice. Teh player can only pass if no possible move is available.
doubles require four (4) moves of each value. by one or more pieces for the total combined value.