Skip to content

Fix movement rules in backgammon #1327

Description

@ktegan

The current backgammon implementation doesn't perfectly handle the corner cases of what is and is not a legal move. To really do this right I think you have to look at all current moves and all subsequent moves.

# Backgammon movement rules from bkgm.com: A player must use both numbers of a roll if
#   this is legally possible (or all four numbers of a double). When only one number can
#   be played, the player must play that number. Or if either number can be played but not
#   both, the player must play the larger one. When neither number can be used, the player
#   loses his turn.  In the case of doubles, when all four numbers cannot be played, the
#   player must play as many numbers as he can.

I have added a number of unit tests (such as test_forced_moves()) in my branch and also made refactored the calculation of legal moves to be correct and more amenable to vector based calculation. Some of the changes in my branch are related to other things so I don't unfortunately have a completely isolated set of commits. Please see my branch at: https://github.com/ktegan/pgx/commits/kegan-backgammon

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions