code: def _update_valid_moves(self):
          '''
          Updates self.valid_moves according to the latest game state.
          Assumes that the board and all hands are non-empty.
          '''
          left_end = self.board.left_end()
          right_end = self.board.right_end()
  
          moves = []
          for d in self.hands[self.turn]:
              if left_end in d:
                  moves.append((d, True))
              # do not double count moves if both of the board's ends have
              # the same value, and a domino can be placed on both of them
              if right_end in d and left_end != right_end:
                  moves.append((d, False))
  
          self.valid_moves = tuple(movesf _update_valid_moves(self):
          '''
          Updates self.valid_moves according to the latest game state.
          Assumes that the board and all hands are non-empty.
          '''
          left_end = self.board.left_end()
          right_end = self.board.right_end()
  
          moves = []
          for d in self.hands[self.turn]:
              if left_end in d:
                  moves.append((d, True))
              # do not double count moves if both of the board's ends have
              # the same value, and a domino can be placed on both of them
              if right_end in d and left_end != right_end:
                  moves.append((d, False))
  
          self.valid_moves = tuple(moves)
docs: Updates self.valid_moves according to the latest game state.
          Assumes that the board and all hands are non-empty.