A utility function is a mathematical mapping from outcomes or states to a real-valued measure of preference, used to formalise an agent’s goals so that decisions can be compared and optimised. In game theory and reinforcement learning it provides the quantity an agent seeks to maximise, underpinning concepts such as expected utility and reward. Utility functions are a core construction of utility theory, applied to model rational choice under uncertainty in both single-agent and multi-agent systems.