Season 2 Episode 3

The Iron Mines

Key scene illustration
Key scene illustration

In which our protagonist discovers that the kingdom's economy is a system too, and it is broken.


The iron mines were the next problem.

They had been operating at a loss for two years. The veins were thinning, the depth was increasing, and the cost of extraction was outpacing the selling price. The mine owner, a portly man named Harren, had come to the mayor in desperation. If the mines closed, the town would lose three hundred jobs and a quarter of its tax revenue. If they stayed open, they would bleed money until they went bankrupt anyway.

Kenji was, at this point, the unofficial "person the mayor called when there was a system problem." He had fixed the clock. He had built the aquifer. He was, in the local parlance, the "strange foreigner who does the impossible." So Harren came to him.

"I have heard you can do things," Harren said, in the careful voice of a man who is not sure if he is being scammed. "The town engineers say you think in systems."

"I do," Kenji said.

"Can you fix my mines?"

"I can look at them. I cannot promise to fix them."

"You can look. That is more than anyone else has offered."

They went to the mines. They were, Kenji saw immediately, in trouble. The iron veins were running diagonally through hard rock, and the miners had been following them in long, winding tunnels that were getting deeper and more dangerous with every foot. The cost of supporting the tunnels, hauling the ore out, and keeping the workers safe was eating all the profit.

Kenji walked through the mines for an entire day. He did not cast spells. He did not give orders. He looked. He asked questions. He climbed down ladders and crawled through narrow passages and talked to the miners, who were a taciturn and practical bunch, and who, by the end of the day, had decided that this strange foreigner was at least not an idiot.

That night, he sat in his room at the guild hall, with Pip orbiting his head and Lian sitting across from him with her notebook open, and he drew a diagram.

"The problem is not that the veins are thin," he said. "The problem is that we are following them. We are paying for the path, not the ore. We are optimizing for the wrong variable."

"What is the right variable?" Lian asked.

"The vein density. We need to find the densest ore first, extract it in straight lines, and only follow the thinner veins if the straight extraction leaves time."

"Straight lines are faster."

"Straight lines are also cheaper. We do not need to support the tunnels as much. We do not need to haul as far. We do not need to send miners down narrow passages where they can barely fit. We can use larger equipment. We can use more workers per tunnel. We can do, in short, an extraction algorithm."

He pulled out a piece of paper and started writing pseudocode. It was not a real spell. It was an algorithm for choosing which tunnels to dig first, based on vein density, depth, and proximity to the surface.

Lian watched, fascinated. "That is a math spell."

"It is a planning spell. We define the inputs. The Compiler generates the actual mining plan. The miners follow the plan. We save money."

"Will it work?"

"I think so. Let me test it."

He spent the next two days refining the algorithm with the help of the mine foreman, a grizzled woman named Sera who had been mining since she was twelve and who understood the rock better than anyone. By the end of day three, they had a new mining plan, focused on the three densest veins, with straight tunnels and a centralized haulage system.

The first new tunnel was dug in four days. The previous tunnels had taken three weeks for less ore. By the end of the month, the mines were profitable again. Harren, who had come to Kenji as a skeptic, sent him a small purse of gold and a hand-written note that said: "You saved three hundred jobs. The town is in your debt."

Kenji gave the purse to Lian. "Your apprenticeship fee. Spend it on books."

Lian's eyes went wide. "That is too much."

"It is exactly enough. Now go buy books."

She went. Kenji watched her leave, and Pip pulsed, amused. The pulse felt like: "Soft."

Kenji sent back: "Yeah. A little."

# WORLD.md (updated)

## Status
- Aquifer: complete, water flowing, drought over
- Iron mines: profitable again, new extraction algorithm
- Reputation: now regional, "the strange foreigner who fixes systems"
- Lian: formally apprenticed, given her first fee

## Lessons
- The path is not the goal. The ore is the goal.
- Algorithms work in the real world as well as they do in code.
- Three hundred jobs saved is a real number, not a metric.