HISTORIES of Russia’s invasion of Ukraine are likely to concentrate on its failure. We are coming to the end of the first phase of the conflict. Quite incredibly, in almost no part of Ukraine are Russian forces sufficiently well organised to make further advances. Indeed, there now seem to be reports of Ukrainian forces making small territorial advances. So much so that President Zelenskyy told the Italian parliament on Tuesday that his country “was on the brink of survival”.

It now seems clear that hubris and self-deception have bred complacency in Russia’s leadership. Confident that its army would face no significant opposition – indeed seemingly believing its own propaganda claims that many Ukrainians would rise up and welcome their liberation from the extremists who had taken over the country, denying it the opportunity to build a closer relationship with Russia – the Russian plan involved small, lightly armed units taking and holding positions for a few hours, while they waited for reinforcements to drive up the road.

Meeting fierce resistance, those advance units were slaughtered. Russia has probably by now lost more soldiers and more equipment than the Soviet Union lost over a decade in Afghanistan.

Perhaps the greatest surprise has been the skill with which President Zelenskyy, a comic actor before he suddenly entered politics, has been able to rally his nation and forge an alliance of necessity with Europe and the US. But also, every day, we see the extent of the Russians’ self-deception in the quiet heroism of people defending the way of life, which they have chosen for their country. Ukraine is not Russia, and Ukrainians are increasingly happy with that. So, boys who really look like they should be in a lecture room are instead learning to kill people. The defenders of Mariupol have refused to surrender, even though their position is completely hopeless.

War is brutal. It is probably the worst possible way to resolve disputes between countries. Beyond the deaths of combatants, and civilians, lives are turned upside down. Ten million Ukrainians have already been displaced from their homes. The basic functions of society, such as food production, health care, and transport, become severely disrupted. War can easily be a precursor of famine and disease. Economically, it is usually ruinous.

The National: National Extra Scottish politics newsletter banner

During the American Civil War, the Union effectively besieged the Confederacy until surrender became inevitable. The First World War saw the failure of the German plan to race to Paris, followed by years of attritional warfare. We also remember the rapid, sweeping advances of the German armies in 1940 and 1941, but the Second World War also ended in the gradual destruction of whole armies, beginning at Stalingrad and ending in Berlin.

It is too early to be certain but it now seems that the initial mobile phase of this war is over. On one side, there is the sheer weight of numbers of the Russian military. On the other, there is the righteous anger of the Ukrainians, and the financial resources of the US and western Europe. There could now be a bloody stalemate, with thousands of deaths every day for years.

When I think about war, it is usually in the happier circumstances of teaching students game theory. In setting up a war of attrition as a game, there is a simple rule. The more patient player almost always wins.

Biologists use similar games to explain the mating rituals of many species. Males face off against each other, with the weaker animal often giving up as soon as the contest starts. The reason is simple: even a ritualised conflict could lead to accidental, but serious, injury. Discretion really is the better part of valour. In such analysis, wars are usually mistakes. Both parties end up believing they are well-placed to win a quick but decisive victory, even though fighting is inevitably costly for them both. It seems clear that in this case the Russian leadership has miscalculated. The foreign minister, Sergei Lavrov, has admitted Russia did not anticipate the united, forceful Western response.

Yet even if it would have been wiser never to have given the order to invade, it seems impossible for Russia to repent of that mistake, seek a ceasefire, and simply retreat. Russia will still be Ukraine’s neighbour. Its army will have killed tens of thousands of people, forced millions to flee its advance and caused damage which will cost hundreds of billions of pounds to repair.

READ MORE: Ukraine crisis: Refugees are dealing with 'ridiculous' bureaucracy getting to UK

Peace will require justice, not vengeance. Delightful as it might be to see Russian military commanders and even political leaders standing trial on criminal charges in the Hague, or in a reformed Russia, that will not rebuild Ukraine.

We may already have many of the tools at our disposal. Western countries have started to impose sanctions against oligarchs, freezing access to Russian state assets. We should honour Roman Abramovich’s intention that the proceeds of the sale of Chelsea Football Club will be used to relieve the suffering caused by the war. Treat these proceeds as a windfall tax, and use them to rebuild Ukraine. And to support Russia. Its people have suffered in this war as well. It is easy to lose sight of that.

But with the country increasingly closed, its government is unlikely to welcome proposals for some sort of partnership for peace based on co-operation, and deepening Russia’s civil society institutions. We are back to cold war attrition and needing patience.