In the winter of 431, in a camp outside the city of Licheng in Shandong, the grain carts were empty.
A clerk had come to the commander with a number. What was left in store would feed the army for three days at most. The troops had been fighting for more than twenty days, falling back from Huatai to Licheng, and the cavalry of Wei was ten or twelve miles away. On clear days the men could see the dust they raised.
Soldiers began to look toward the supply carts. Some of them were already talking in low voices.
The commander, Tan Daoji, gave an order. Bring what rice remains into the middle of the camp and pile it up. Then he gave a second order. Tonight, the whole camp will measure grain.
That night the camp was lit up. Men measured rice by the bushel, one bushel at a time, and shouted the tally as they went. The counting carried across the whole encampment. Scouts from the northern army lay on the slope outside and watched the firelight on those heaps, and listened to the numbers being called.
What they were looking at was sand.
The rice was a thin layer spread over the top.
In the morning the scouts went back and reported that the grain piles in the southern camp were higher than they had been the day before. The Wei commander was quiet for a while. Then he gave his order. No pursuit.
From Pengcheng to Luoyang
Tan Daoji came from Pengcheng, though some sources give his family home as Jinxiang in Gaoping. He grew up in Jingkou, at the mouth of the Yangtze. His parents died when he was small and he was raised by an elder brother. The two of them joined the army of Liu Yu together.
In those years the army was the only ladder a poor boy could climb.
In 416 Liu Yu launched a campaign north against the state of Later Qin, and Tan Daoji went as one of the two vanguard commanders. The army moved up the Huai and the Fei rivers toward the northwest. He reached Xiangcheng first, and its commander surrendered without a fight. At Xincai the defender held out, so he stormed the wall and killed him. Then he took Xuchang and captured the governor of Yingchuan.
Luoyang was next. The Qin commander inside the city sent to the west for help. The relief column never arrived in time. Tan Daoji joined forces with the other columns and closed in from four sides. The gates opened.
By the end of that advance he had more than four thousand prisoners.
The custom of the time allowed a commander to kill them or sell them as slaves. The camp argued about it for a night. Some said they could not be fed on the march. Some said that if they were released they would simply come back with weapons.
Tan Daoji said one sentence, which the dynastic history preserves. We are punishing the guilty and comforting the people. That work begins today.
He let them all go.
Four thousand men scattered back to their villages across Henan. When word spread, the chiefs of several fortified settlements came in to submit. Liu Yu held the Guanzhong region for only a few months, and those men were part of the reason he held it at all.
The following year the region was lost anyway, and the garrisons were wiped out. The prisoners Tan Daoji released did not change the outcome. But the phrase about punishing the guilty and comforting the people stayed attached to his name.
When the Liu Song dynasty was founded, he was made a duke. In the 420s he took part in the removal of one emperor and the installation of another, and then in the suppression of a rebellion by a governor. By the early 430s he was a minister of state and the military commander of the middle Yangtze.
He was, by then, the last senior field commander the southern dynasty had.
Thirty Battles on the Road
In 430 the emperor ordered a northern campaign.
It went well at first. The water forces entered the Yellow River and moved west, retaking Huatai, Hulao and Luoyang. The boats were new, the armour was in good order, and the towns of the old Qin territory opened their gates as the columns approached. The court was already discussing how to administer the recovered counties of Henan.
Then the river froze.
The northern cavalry came south. The southern boats were locked in the ice, unable to advance or withdraw. The commander ordered them burned and the army to walk home. The baggage was abandoned along the road. Men walked on the ice until their shoes froze to their feet, and by the time they reached Pengcheng half the army had dispersed.
That was the first northern campaign of the reign, and it failed cleanly.
The emperor called Tan Daoji north to cover the retreat.
He had few men and little grain. In twenty days he fought more than thirty engagements, and he won most of them. The northern commanders had taken losses and began to steer around his banner when they saw it.
One of those fights took place in a small town where his men were surrounded inside an earthen wall. He went up on the wall himself and held the gap until dark, then broke out. He had fought that kind of battle all his life. He was not a commander who won a war in a single afternoon. He was the kind who turned a defeat into a draw, and a draw into an orderly withdrawal.
This time what he had to drag out of the north was a hungry army.
The southern dynasties had a structural weakness that no general could fix. Their strength was on the Yangtze, in the river fleet. North of the Huai, supply depended on a chain of waterways. In autumn the boats could still move. In winter the rivers froze and the boats became a liability, while grain carts on the roads were slow and easy for cavalry to cut off.
That is why almost every northern campaign of the period ended the same way. They could get in. They could not stay.
Tan Daoji had reached Licheng, deep in enemy country, when the supply line was cut.

The Night of Counting
The History of the Southern Dynasties gives the trick about twenty characters. Tan Daoji, it says, at night counted sand by the tally and scattered the small remainder of rice on top. At dawn the northern army concluded that his supplies were ample, and did not pursue.
The tally was the count called out when grain was measured. In army stores, grain was measured bushel by bushel, and each bushel was called aloud and marked with a slip. The counting was not decoration. It was an audit, performed in public.
That night the shouting in the southern camp did not stop. By the end, the men inside the camp believed it too. That was how the morale came back.
The risk was enormous. The enemy scouts were a few dozen paces outside the wall. One man walking up to the heaps would have seen the sand under the thin layer of rice, and the whole army would have died there. Tan Daoji was betting on two things. It was dark, and the scouts would not come close. And people believe what they see and what they hear counted out loud.
At dawn the army struck camp and moved south. The northern cavalry did not follow.
Before he left, he did one more thing.
He had the men put on full armour. He himself put on white robes and took a seat in a carriage, and the army marched out of the gate in good order, at walking pace, as if there were nothing behind them and nothing ahead.
The northern commander watched from a distance and suspected an ambush. He pulled his men back several miles.
The army came home intact.
After that battle his name travelled north. The Wei court had his portrait painted and hung it on a wall, believing it would ward off evil. The story is in the standard history, and it sounds like a joke, but it tells you how much they feared him.
The dynastic historians later wrote that his reputation soared. In fact he had won nothing. He had merely avoided losing everything.
The Great Wall
In the winter of 435 the emperor fell ill.
From his sickbed he sent an order recalling Tan Daoji to the capital.
His wife, Lady Xiang, did not trust it. A merit that rises above the world, she told him, is what the Daoists warn against. Now they summon you when there is no war. The trouble is coming.
He went anyway.
He arrived in the capital and did nothing for a month. The emperor improved and issued an order sending him back to his post on the Yangtze. He boarded a boat. Before it left the dock the emperor worsened again.
The prince of Pengcheng, Liu Yikang, came down to the waterfront and said there would be a banquet in his honour. He turned back.
When he turned back, they arrested him.
In the third month of 436 the order came down. The charge was that he had distributed money, gathered men of no fixed employment, and planned treason while the emperor lay ill. He was executed with his son Tan Zhi and nine other men of the family. Two of his best officers, compared by contemporaries to Zhang Fei and Guan Yu, were killed with him.
One history says the emperor issued that order. Another, written two centuries later, says the prince forged it. The two accounts have been argued over ever since.
There is one detail both agree on. Before the arrest, someone at court had asked a question that decided the case. How do we know he is not a second Sima Yi.
That was the real charge. Sima Yi had been the regent who quietly took a throne from the family he served. Tan Daoji had sons in the army, all of them capable. His officers were men of known ferocity. A sick emperor looking at that family could not sleep.
At the execution he was furious. His eyes were wide, and he tore the cloth from his head and threw it on the ground.
You have destroyed your own Great Wall.
For a Western reader the image needs one line of explanation. The Great Wall was the long fortified line that kept the northern cavalry out of China. To tear it down yourself was to invite the enemy in with your own hands.
After his death someone in the capital made a song about a white dove and a wrongful killing. The northern court heard the news and said that with Daoji gone, the southerners had nothing left to fear.
From then on the cavalry came south every year.
His sons were almost all killed. One grandson, Tan Ru, was pardoned decades later under a later emperor and given a minor honorary post. The family never produced another general.
On Stone City
In 450 the southern army marched north again and was destroyed.
The northern emperor led his own cavalry south, with a force the sources inflate to a million and modern estimates put in the hundreds of thousands. The southern armies fell back. The northern horse reached Guabu on the north bank of the Yangtze, directly across the water from the capital. The river was put under martial law, and people inside the city could see the fires on the far bank.
That year the counties north of the river were stripped. The histories use two phrases for it. The counties collapsed at the first sight of the enemy. The ground was bare for a thousand li.
The emperor climbed Stone City, the fortress on the hill above the river, and looked north.
He looked for a long time. Then he said: if Daoji were here, would it have come to this.
It was fourteen years since the execution.
The histories also preserve the other side of that sentence. In the same year, discussing the loss of Henan, the emperor still blamed Tan Daoji, saying that he had kept the enemy alive to justify his own position. He mourned the man and still called him a traitor.
Fourteen years after the death, the account was still open.
What happened to the cloth he threw on the ground, no one recorded. Whether a jailer picked it up or the wind took it into a ditch, the histories do not say. They record only the gesture and the sentence.
Later writers traced the origin of the Thirty Six Stratagems to him, because a southern history contains a line about the thirty six plans of Duke Tan, and the best of them is to run away. That line refers to exactly this retreat from Licheng. Whether the book that everyone now quotes was written by him, or written a thousand years later, is still disputed.
Near Licheng there is said to be a mound called the grain tomb, where the sand was measured. Several counties in Shandong each have one. Nobody can say which is real.
What is certain is the counting. One bushel, two, three. It went on until daylight, and the cavalry never came.