A function that takes the state of a system, which can be anything the owner of the utility function can interact with, and is given certain goals, which can be anything so long as they are logically consistent e.g. making money or gathering votes. It then returns a number, representing how "good" this state is e.g. number of votes. All goal based systems must contain one, including humans. As using a utility function is very inefficient, this is often replaced with a set of adaptations, that are known to result in high values, as a computational short cut. This can lead to cases where something that wasn't in the ancestral environment interferes with the adaptation, leading to a state that should have a low utility value, but is still reached by the adaptations. e.g. sweetness is used to determine what's good to eat. This worked, until chocolate and other artificial foods happened.

In theory, a goal based system would work as follows:
1. Let A be a list [a1,a2,a3,...] of all possible actions
2. For each action do steps 3-6
3. Let i be the current action
4. Let R be a list [r1,r2,r3,...] of all possible results of taking i, along with the probability's of happening.
5. Take the utility function of each result, and multiply this by the probability of happening
6. Sum the results of the previous step, to get the utility of i
7. Take the action that has the highest utility value

The above system would be extremely inefficient, but would achieve its goals.

example:
a lottery has a 1/1000 chance of winning $100, and costs 1 dollar the enter.
A = [play lottery,don't play lottery]

utility of play lottery = (0.001*(100-1)) + (0.999*(0-1))
utility of play lottery = 0.099 - 0.999
utility of play lottery = -$0.9

utility of don't play lottery = (1*0) = 0
utility of don't play lottery>utility of play lottery
conclusion: don't play