def expected_utility(a, s, U, mdp):
    """The expected utility of doing a in state s, according to the MDP and U."""
    # print(sum([p * U[s1] for (p, s1) in mdp.T()[a][s]]))
    R, T, beta = mdp.R(), mdp.T(), mdp.beta
    return R[a][s] + beta * sum([p * U[s1] for (p, s1) in T[a][s]])