def pig_actions_d(state):
    """The legal actions from a state. Usually, ["roll", "hold"].
    Exceptions: If double is "double", can only "accept" or "decline".
    Can't "hold" if pending is 0.
    If double is 1, can "double" (in addition to other moves).
    (If double > 1, cannot "double").
    """
    # state is like before, but with one more component, double,
    # which is 1 or 2 to denote the value of the game, or 'double'
    # for the moment at which one player has doubled and is waiting
    # for the other to accept or decline
    # --------
    # p in (0,1); me in (0, goal), you in (0, goal)
    # pending in (0, goal), double in [1, 2, 'double', 'accept']
    # return in ['roll', 'hold', 'accept', 'decline', 'double']
    (p, me, you, pending, double) = state
    
    # # you have to accept or decline when your opponent just doubled.
    # if double == 'double':
    #     return set(['decline', 'accept'])
    # # you can continue roll and hold when your opponent accept your double
    # if double == 'accept':
    #     return set(['roll', 'hold'])
    # # you can continue roll and hold and raise to 'double' mode
    # if double == 1 and pending == 0:
    #     return set(['roll', 'double'])
    # elif double == 1 and pending != 0:
    #     return set(['roll', 'hold', 'double'])
    # # you can continue roll and hold, but you cannot raise any more
    # if double == 2 and pending == 0:
    #     return set(['roll'])
    # elif double == 2 and pending != 0:
    #     return set(['roll', 'hold'])
    actions = (['accept', 'decline'] if double == 'double' else
                ['roll', 'hold'] if pending else 
                ['roll'])
    if double == 1: actions.append("double")
    return actions