Using a DQN with a variable amount of Valid Moves per turn for a Board Game
I think instead of:

if np.argmax(act_values[0]) in actions_allowed:
        return np.argmax(act_values[0])


you can use something like:

if np.argmax(actions_allowed_values[0]):
        return np.argmax(actions_allowed_values[0])


So you didn't random your act if the best action is not allowed, but you choose the best action that allowed. You can do that by checking for each action value, whether it is a valid action or not, then take the best value. Or you can change invalid action value to a very small number.