
Just having goals isn’t good enough because often we may  have several actions which all satisfy our goal so we need some way of working  out the most efficient one. A utility function maps each state after each  action to a real number representing how efficiently each action achieves the  goal. This is useful when we either have many actions all solving the same goal  or when we have many goals that can be satisfied and we need to choose an  action to perf orm.
orm.
For example let’s show our mars Lander on the surface of mars with an obstacle in its way. In a goal based agent it is uncertain which path will be taken by the agent and some a re clearly not as efficient as others but in a utility based agent the best path will have the best output from the utility function and that path will be chosen.
Sources: (Artificial Intelligence: A Modern Approach by Stuart Russell and Peter Novig), Reference »