The deregulation of electricity markets has continued apace around the globe. The best structure for deregulated markets is a subject of much debate, and the consequences of poor structural choices can be dramatic. Understanding the effect of structure on behavior is essential, but the traditional economics approaches of field studies and experimental studies are particularly hard to conduct in relation to electricity markets. This paper describes an agent based computational economics approach for studying the effect of alternative structures and mechanisms on behavior in electricity markets. Autonomous adaptive agents, using hierarchical learning classifier systems, learn through competition in a simulated model of the UK market in electricity generation. The complex agent structure was developed through a sequence of experimentation to test whether it was capable of meeting the following requirements: first, that the agents are able to learn optimal strategies when competing against nonadaptive agents; second, that the agents are able to learn strategies observable in the real world when competing against other adaptive agents; and third, that cooperation without explicit communication can evolve in certain market situations. The potential benefit of an evolutionary economics approach to market modeling is demonstrated by examining the effects of alternative payment mechanisms on the behavior of agents.