If we think through the North Korea nuclear weapons dilemma using game theory, one aspect of the problem deserves more attention, namely the age of the country’s leader, Kim Jong Un: 33.


Because peaceful exile doesn’t appear to be an option — his escaping the country safely would be hard — Kim needs strategies for hanging on to power for 50 years or more. That’s a tall order, but it helps us understand that his apparently crazy tactics are probably driven by some very reasonable calculations, albeit selfish and evil ones.


It is very difficult to predict the world a half-century out. Fifty years ago, China was just coming out of the Cultural Revolution, and Japan’s rise was not yet so evident. North Korea was possibly still richer than the South, which in 1960 was one of the poorest countries in the world. It’s unlikely anyone had a reasonable inkling of where things would stand today.


So if you are a dictator planning for long-term survival under a wide range of possible outcomes, what might you do? You don’t know who your enemies and your friends will be over those 50 years, so you will choose a porcupine-like strategy and appear prickly to everyone.


We Americans tend to think of Kim as an irritant to our plans, but his natural enemy in the long run is China. It is easier for North Korea to threaten Chinese cities with weapons, and its nuclear status stands in China’s way of becoming the dominant regional power in East Asia. Chinese public opinion has already turned against North Korea, and leaders wonder whether a more reliable, pro-Chinese option to Kim might be installed. Since assuming power, Kim has gone after the generals and family members with the strongest ties to China.


One way to interpret Kim’s spat with President Donald Trump is that he is signaling to the Chinese that they shouldn’t try to take him down because he is willing to countenance “crazy” retaliation. In this view, Beijing is a more likely target for one of his nukes than is Seattle.


More radically, think of Kim as auditioning to the U.S., Japan, South Korea and India as a potential buffer against Chinese expansion. If he played his hand more passively and calmly, hardly anyone would think that such a small country had this capacity. By picking a fight with the U.S., he is showing the ability to deter just about anyone.


Another possible scenario from Kim’s perspective is that external pressures and sanctions rise, and North Korea can’t survive as a regional nuclear pariah. If this doesn’t seem likely today, remember we are talking about the next 50 years. So if Kim’s belligerence induces Japan or maybe South Korea to develop nuclear deterrents, that would take some of the pressure off him, as nuclear proliferation would become the regional default. Kim is probably more concerned with sheer survival than with managing other shifts in the balance of power.


All good long-run strategies for Kim should have some short-term payoffs. Russian President Vladimir Putin seems to be supporting the North Korean regime, and has possibly allowed Soviet-era nuclear technology to make its way to them. Kim has earned his country one very powerful protector, but he would be unwise to consider Russia a reliable friend in the longer run. The Russians too have to fear North Korean nuclear weapons.


A common criticism of game-theoretic analyses is that individuals are simply not very calculating and rational. But the evidence shows a lot of North Korean skill at deliberate strategy. Kim was considered a weak successor to his father, yet he cemented his power decisively. He developed intercontinental ballistic missile capabilities and expanded the nuclear arsenal much more quickly than most observers had expected. He brought reforms and unexpectedly high rates of growth to the North Korean economy, and he seems to have retained the loyalty of a significant fraction of the North Korean populace. Those who have negotiated with the North Koreans usually consider them sophisticated and rational, albeit sometimes underinformed.


It’s mostly good news that Kim is probably more rational than his rhetoric would indicate. The American and South Korean equity markets are hitting new highs, and the Japanese market is doing fine, which hardly seems compatible with a pending nuclear war. The point is not that markets are always right in their bullishness, but at least equity valuations are not completely crazy.


Alternatively, you still might think that Kim and the markets really are insane. But then how about you? We all know that a sane and smart worrywart would know to sell everything and short all those markets, and surely you did that some time ago?


Tyler Cowen is a Bloomberg View columnist. For more columns from Bloomberg View, visit http://www.bloomberg.com/view.