This simulation visualizes George Akerlof's "The Market for Lemons"—a foundational model in information economics demonstrating how information asymmetry causes high-quality goods ("Peaches") to exit the market when buyers cannot distinguish them from low-quality goods ("Lemons"), eventually leading to market collapse.
The simulation uses an Agent-Based Model (ABM) with 200 agents: 100 sellers (50 Peaches, 50 Lemons) and 100 buyers. Sellers and buyers move around the canvas like a flock. When a buyer approaches a seller, they attempt a transaction at the market price, which is based on the average expected quality of cars currently in the market. Sellers only accept offers that exceed their cost to produce.
The key insight: Buyers cannot distinguish quality until after purchase. Initially, the market price reflects the 50/50 split ($750 = average of $500 and $1000). Peach sellers (cost $800) refuse this price and become frustrated. After multiple failed attempts, they exit the market. As Peaches leave, the average quality drops, buyers lower their offers, and the "death spiral" accelerates until only Lemons remain.
NOTE: By default, all cars appear Gray (buyer's perspective). Use the "God Mode" toggle to reveal the true quality: Blue for Peaches, Orange for Lemons. Watch as Gray dots disappear—then toggle God Mode to see that only Orange (Lemons) remain. This is the "Aha!" moment that demonstrates the market failure.
Mathematical Foundation
The Market for Lemons model demonstrates how information asymmetry creates a market failure. The key parameters are:
| Good Type |
Cost to Seller |
Value to Buyer |
Initial Count |
| Peach (High Quality) |
$800 |
$1,000 |
50 |
| Lemon (Low Quality) |
$500 |
$500 |
50 |
The Market Price is determined by the expected value based on the current ratio of goods:
Pmarket = (ProbPeach × ValuePeach) + (ProbLemon × ValueLemon)
Initially (50/50 split): Pmarket = (0.5 × $1,000) + (0.5 × $500) = $750
The Problem: Since $750 < $800 (Peach cost), Peach sellers refuse to sell. Only Lemon sellers ($500 cost) accept. As Peaches exit, the ratio shifts toward 100% Lemons, causing:
Pmarket → $500 (only Lemons remain)
This creates a "Death Spiral" where high-quality goods systematically exit the market, leaving only low-quality goods—a classic example of adverse selection in economics.
Agent-Based Modeling vs. Differential Equation Models
Unlike many traditional economic models based on differential equations, this simulation uses an Agent-Based Model (ABM)—a discrete, behavior-based computational approach.
Traditional Differential Equation Approach:
- Continuous mathematics: Uses differential equations and calculus (e.g., dP/dt = α(D(P) - S(P)))
- Aggregate level: Models populations as continuous variables (e.g., price P(t) at time t)
- Top-down: Starts with system-level equations that govern aggregate behavior
- Equilibrium-focused: Often solves for steady states and stability conditions
- Assumptions: Homogeneous agents, perfect information, market equilibrium
Agent-Based Model Approach (This Simulation):
- Discrete simulation: Uses time-stepped, rule-based behavior (simple if-then logic)
- Individual level: Each agent has its own state and decision rules
- Bottom-up: System behavior emerges from individual agent interactions
- Dynamic and path-dependent: History matters, outcomes depend on initial conditions
- Realistic complexity: Heterogeneous agents, local interactions, information asymmetry
Key Differences:
| Aspect |
Differential Equations |
Agent-Based Models |
| Nature |
Continuous, mathematical |
Discrete, computational |
| Level |
Aggregate (market price) |
Individual (each agent) |
| Method |
Solve equations |
Simulate rules |
| Time |
Continuous (dt) |
Discrete (frames/ticks) |
| Assumptions |
Homogeneous, equilibrium |
Heterogeneous, dynamic |
| Causality |
Direct (equation shows cause) |
Indirect (emerges from rules) |
Why ABM for "Market for Lemons"?
Akerlof's model is particularly well-suited to agent-based modeling because:
- Information asymmetry: Agents have different information (buyers cannot observe quality)
- Heterogeneous agents: Different types (Peaches vs. Lemons), different patience levels, different starting funds
- Local interactions: Transactions occur only when agents meet nearby (spatial dimension)
- Emergent collapse: Market failure emerges from individual decisions, not pre-programmed equations
- Path dependence: Initial conditions matter (lemon ratio, buyer patience, randomized funds)
- Visualization: Can observe individual agent behavior and understand the mechanism intuitively
Example of Discrete Rules (Not Differential Equations):
// Movement: Discrete position update
if (this.active) {
this.x += this.vx;
this.y += this.vy;
}
// Operating costs: Discrete subtraction
if (this.role === 'seller') {
this.funds -= 0.1;
}
// Bankruptcy: Discrete state change
if (this.funds <= 0) {
this.active = false;
}
// Transaction decision: Discrete event
if (marketPrice >= seller.getCost()) {
// Transaction happens
}
In contrast, a differential equation approach would model this as continuous functions:
dPpeach/dt = -α·Ppeach (Peaches exit)
dPlemon/dt = +β·Plemon (Lemons dominate)
However, such equations would miss crucial features like how buyers learn about quality, individual frustration thresholds, spatial interactions, and staggered bankruptcy timing—all of which are naturally captured in the agent-based approach.
Why Information Asymmetry Causes Market Failure
In a market with perfect information, buyers would pay $1,000 for Peaches and $500 for Lemons, and both types would trade. However, when buyers cannot distinguish quality (information asymmetry), they base their offers on the expected average quality of the market.
The Death Spiral - A Three-Act Tragedy:
- Act 1 - Adverse Selection (Initial State): Market price = $750 (average of $1,000 and $500). Lemon sellers ($500 cost) sell happily. Peach sellers ($800 cost) refuse and become frustrated.
- Act 1 - Peaches Exit: After multiple failed attempts, frustrated Peach sellers leave the market permanently. As Peaches exit, the ratio shifts toward more Lemons. Market price drops as average quality deteriorates.
- Act 2 - Market Collapse: Buyers realize they're purchasing Lemons and lose trust. After buying a certain number of bad deals (configurable "Buyer Patience"), buyers leave the market permanently. As buyers exit, remaining buyers become increasingly scarce.
- Act 3 - Market Atrophy (Seller Bankruptcy): With fewer buyers, Lemon sellers cannot make sales. All sellers face operating costs (rent, inventory, time) that drain their funds every frame. Without sales, sellers cannot replenish funds. One by one, sellers go bankrupt and exit the market. No new sellers enter a dead market.
- Final Act - Total Extinction: The market completely collapses. All Peaches are gone. All Buyers are gone. All Lemons are gone. The screen becomes empty—total market death.
Seller Bankruptcy Mechanism
The simulation implements a bankruptcy mechanism to model realistic market dynamics:
- Starting Funds: Each seller starts with randomized funds (between $50 and $150) to ensure staggered exits and natural decline curves.
- Operating Costs: Sellers lose $0.1 per frame to represent ongoing costs (rent, inventory, time). This represents the cost of staying in business.
- Profit from Sales: When a seller makes a sale, they receive $50 in profit. This allows them to sustain operations longer.
- Bankruptcy: If a seller's funds drop to $0 or below, they go bankrupt and exit the market permanently. Bankrupt sellers are not replaced.
- No Buyers = No Entry: Lemon sellers only respawn when a Lemon is sold and there are still active buyers in the market. If all buyers have left, no new sellers enter—the market is dead.
Why This Matters: In a real economy, scammers (Lemon sellers) cannot survive if there are no victims (Buyers). They have operating costs that drain resources. Without sales, they eventually go bankrupt and exit. This demonstrates Market Atrophy—the complete death of a market when trust is destroyed.
Real-World Examples:
- Used Car Market: Sellers know car quality; buyers don't. High-quality cars exit, leaving only "lemons."
- Health Insurance: When insurers can't screen, healthy people opt out, leaving only sick people (adverse selection).
- Online Marketplaces: Without reviews/reputation, quality sellers exit, platform becomes a "lemon market."
Solutions to Information Asymmetry
The model explains why markets develop signaling mechanisms:
- Warranties: Sellers of quality goods offer warranties (costly for low-quality sellers).
- Reputation Systems: Online reviews, ratings, certifications.
- Screening: Insurers require medical exams; employers use interviews/tests.
- Branding: Established brands signal quality (reputation is valuable).
Try This Experiment
Watch the simulation with God Mode OFF (default). You'll see gray dots (cars) simply disappearing. Then toggle "God Mode" to reveal the truth: only Orange (Lemons) remain, while all Blue (Peaches) have fled. This is the powerful visual demonstration of market failure due to information asymmetry.
Usage Example
Follow these steps to explore the Market for Lemons and information asymmetry:
-
Initial Setup: When you first load the simulation, you'll see 200 agents moving around the canvas:
- 100 Sellers: 50 Peaches (high quality, cost $800) and 50 Lemons (low quality, cost $500)
- 100 Buyers: Looking to purchase cars
- Gray Dots: All sellers appear gray (buyer's perspective - cannot distinguish quality)
- Rings: Buyers appear as hollow circles
-
Understanding the Market Price: The market price starts at $750 (the average of $1,000 and $500). This price is based on the expected value given a 50/50 split of Peaches and Lemons. Buyers offer this price to all sellers they encounter.
-
Start the Simulation: Click "Start" to begin the market interactions. Watch how:
- Buyers approach sellers and attempt transactions at the market price
- Lemon sellers ($500 cost) accept $750 offers and leave the market
- Peach sellers ($800 cost) refuse $750 offers and become frustrated (red rings appear)
- After 5 failed attempts, frustrated Peach sellers exit the market
-
The Death Spiral: As Peaches exit, observe the market price drop. The statistics panel shows:
- Market price decreasing as average quality deteriorates
- Peach count dropping to zero
- Lemon count remaining stable
- The chart showing the ratio of Peaches vs Lemons over time
-
Toggle God Mode: This is the key educational moment! With God Mode OFF (default), you see gray dots disappearing. Toggle "God Mode" ON to reveal the truth:
- Blue dots: Peaches (high quality) - you'll see they've all left
- Orange dots: Lemons (low quality) - only these remain
- This visual "reveal" demonstrates the market failure powerfully
-
Watch the Chart: The time series chart shows the "death spiral" visually:
- Blue line (Peaches) decreases to zero
- Orange line (Lemons) remains stable
- This demonstrates how information asymmetry causes adverse selection
-
Reset and Experiment: Click "Reset" to restart. Try running with God Mode ON from the start to see which agents are Peaches vs Lemons as they exit. This helps understand the mechanism visually.
Tip: The key insight is that information asymmetry causes markets to fail. When buyers cannot distinguish quality, they offer prices based on average quality. High-quality sellers (whose costs exceed the average price) exit, causing average quality to drop further. This creates a "death spiral" where only low-quality goods remain. The solution is signaling—mechanisms that allow quality to be revealed (warranties, reputation, certifications).
Parameters
Followings are short descriptions on each parameter
-
Market Price: The price buyers offer based on expected value. Calculated as: (Prob_Peach × $1,000) + (Prob_Lemon × $500). Starts at $750 with 50/50 split, decreases as Peaches exit.
-
Peach Cost: The cost to sellers for producing a high-quality car ($800). Peach sellers refuse to sell below this price.
-
Lemon Cost: The cost to sellers for producing a low-quality car ($500). Lemon sellers accept any offer above this price.
-
Peach Value: The true value to buyers for a high-quality car ($1,000). Buyers would pay this if they could distinguish quality.
-
Lemon Value: The true value to buyers for a low-quality car ($500). Equal to production cost.
-
Frustration Threshold: The number of failed transaction attempts before a Peach seller exits the market (default: 5). Higher values slow the collapse; lower values accelerate it.
-
Interaction Radius: The distance at which buyers can attempt transactions with sellers (default: 40 pixels). Controls transaction frequency.
-
Starting Funds: Each seller starts with randomized funds (between $50 and $150) to ensure staggered exits and natural decline curves. Randomization prevents synchronized bankruptcy.
-
Operating Cost: Sellers lose $0.1 per frame to represent ongoing costs (rent, inventory, time). This represents the cost of staying in business.
-
Profit from Sale: When a seller makes a sale, they receive $50 in profit. This allows them to sustain operations longer. Without sales, sellers eventually go bankrupt.
-
Bankruptcy Threshold: If a seller's funds drop to $0 or below, they go bankrupt and exit the market permanently. Bankrupt sellers are not replaced.
Buttons and Controls
Followings are short descriptions on each control
-
Start/Stop: Toggles the simulation. When running, the button shows "Stop" and turns red. Click to pause and observe the current market state. Agents move continuously, and transactions occur when buyers approach sellers.
-
Reset: Stops the simulation and resets to initial state (50 Peaches, 50 Lemons, 100 Buyers). Clears market history and statistics. Use this to start fresh experiments.
-
God Mode Toggle: The key educational feature. When OFF (default), all sellers appear Gray (buyer's perspective - cannot distinguish quality). When ON, sellers appear in true colors: Blue for Peaches, Orange for Lemons. Use this to see which agents are exiting and understand the mechanism visually.
-
Simulation Settings: Adjust these parameters to experiment with different market scenarios and see "What does it take to save the market?":
- Buyer Patience (1-20, default: 5): How many bad deals (Lemons) a buyer will tolerate before leaving the market permanently. Higher values slow the buyer exodus; lower values accelerate it. Experiment to find the critical threshold where buyers stay long enough to keep the market alive.
- Initial Lemon Ratio (0-100%, default: 50%): The percentage of sellers that are Lemons at the start. Lower ratios (e.g., 10%) may show stable equilibrium where Peaches survive because the average price remains high enough. This demonstrates Akerlof's theory: the market only fails if the "poison" exceeds a critical threshold.
- Information Cost ($0-$100, default: $0): The cost for buyers to check quality before buying. If > $0, buyers can identify Lemons and avoid them. This prevents market collapse by allowing quality signals. Experiment with different values to see how information disclosure saves markets.
Note: Click "Reset" after changing slider values to apply the new settings and restart the simulation.
Interaction and Visualization
-
Agent Visualization:
- Sellers: Filled circles. Color depends on God Mode setting (Gray by default, Blue/Orange in God Mode).
- Buyers: Hollow circles (rings), always gray.
- Frustrated Peaches: Red rings appear around Peach sellers who have failed multiple transactions.
- Exiting Agents: Sellers leaving the market move off-screen and fade out.
-
Transaction Mechanism:
- Buyers move randomly (Boids-like wandering)
- When a buyer approaches a seller (within interaction radius), they offer the market price
- If offer ≥ seller's cost: Transaction succeeds (gold flash animation), seller leaves market
- If offer < seller's cost: Transaction fails, Peach seller's frustration increases
- Peach sellers exit after reaching frustration threshold
-
Statistics Panel: Real-time display of:
- Market Price (current expected value based on remaining goods)
- Peaches Remaining (count and percentage)
- Lemons Remaining (count and percentage)
- Buyers Count
- Total Sellers Count
-
Market Composition Chart: Time series visualization showing:
- Blue line: Number of Peaches over time (decreases to zero)
- Orange line: Number of Lemons over time (remains stable)
- Demonstrates the "death spiral" as Peaches systematically exit