A striking feature of human decision making is the fourfold pattern of risk attitudes, involving risk-averse behavior in situations of unlikely losses and likely gains, but risk-seeking behavior in response to likely losses and unlikely gains. Current theories to explain this pattern assume particular psychological processes to reproduce empirical observations, but do not address whether it is adaptive for the decision maker to respond to risk in this way. Here, drawing on insights from behavioral ecology, we build an evolutionary model of risk-sensitive behavior, to investigate whether particular types of environmental conditions could favor a fourfold pattern of risk attitudes. We consider an individual foraging in a changing environment, where energy is needed to prevent starvation and build up reserves for reproduction. The outcome, in terms of reproductive value (a rigorous measure of evolutionary success), of a one-off choice between a risky and a safe gain, or between a risky and a safe loss, determines the risk-sensitive behavior we should expect to see in this environment. Our results show that the fourfold pattern of risk attitudes may be adaptive in an environment in which conditions vary stochastically but are autocorrelated in time. In such an environment the current options provide information about the likely environmental conditions in the future, which affect the optimal pattern of risk sensitivity. Our model predicts that risk preferences should be both path dependent and affected by the decision maker's current state.