Let's say you are the general or leader of an army in ancient or medieval times. You fight and you lose a battle, a siege or suffer significant losses due to attrition. What would you do. What would a fairly organized army even be able to do and what would they avoid. How would they motivate their forces in this case?
I know there are some huge "Ifs" in this question, but you often hear about the winning side of military strategy but rarely about the losing side.
The question leaves open a wide and vague area for contemplation. Since, simply "losing a battle" is still a category of several possible outcomes and circumstances. There many ways and extents to which one can "lose". And depending on the condition a general finds themselves in, the decisions they make will change accordingly. So, I will try and cover a number of circumstances I think fall into this category of "losing".
Let's say that the army of the general is defeated but retreats in order : This can be a situation when the battle is especially hard fought, but the winning side, although inflicting significant losses upon the enemy, is unable to rout them, while the losing side has taken considerable losses and the general finds his situation untenable, therefore orders an organised and quite retreat after a day of battle, and retreats to a tactically conducive location, in order to collect the troops that had been routed during the battle. Here it must be kept in mind that routes weren't an individual phenomenon, meaning if a unit found it's situation untenable at a point of a battle and lost morale, the men would usually retreat in the same direction and would try and maintain themselves in a group. This would bolster their chances of fending off persuing enemy cavalry, of surviving and regrouping. This also meant that if a general wanted to find and regroup his scattered forces, he would not have to send thousands of cavalrymen in all direction to pick up individual men, but rather officers who would recognise and recollect their units that might have fled.
Let's assume that this task is accomplished, now the general is left with a few options and these depend on the actions of the enemy and the tactical and geographical position of the general. For example, we can assume that the enemy army after a day of battle, is probably tired, and will persue the beaten enemy to destroy him thoroughly, the next morning. This means that the general can and usually did force march his troops, to a tactically advantageous position, while still defending their capital, this can be a fort, a city, a geographically defensive position etc.
Now, let's say that the army of the general was routed, which means units fled with little cohesion, and the general, either escaped with his guard or reserves or was captured. In case of capture, there is no more contemplation of strategy that we are concerned with. In case of the former, meaning let's say that the general did manage to retreat with his guard, he's left with limited options. He can retreat to a strong defensive position, again, fort, or city. He can try and regroup his armies as mentioned above or he can try and replenish his troops if he or his monarch can afford to do so, via mercenaries, calling forth reserves etc. If neither are viable options, well, then there's the option of doing what Babur and/or Maharana Pratap did. Abandon the capital, and then, either create a new centre of power from where you can hopefully reverse your losses as Babur did. Or, retreat to jungles and mountains, as Pratap did, and fight a long and sustained guerilla war, admittedly, this is a path that few kings or generals have followed and requires an amount of extraordinary willpower, charisma and skill.
To give you some context as to what Babur resorted to as a long term strategy here's some context. Zahir-ud-din Mohammed Babur, was the eldest of Umar Sheikh Mirza, who was governor of Ferghana, which is a region in eastern Uzbekistan. Babur was by lineage the great-great grandson of Timur. Babur's early military career was full of frustrations. Born in 1483, he had assumed the Throne of his father at age 12, in the year 1494. He conquered Samarkand two years later, only to lose Fergana soon after. In his attempts to reconquer Fergana, he lost control of Samarkand. In 1501, his attempt to recapture both the regions failed when Muhammad Shaybani Khan the founder of the Shaybanid dynasty, defeated him. He conquered Kabul, in 1504, after having being driven away from his patrimony and homeland. He formed an alliance with the Safavid Shah Ismail I, to take parts of Turkestan as well as Samarkand itself only to lose them again to the Shaybanids.
Hence, he had decided to give up on the dreams of taking back Ferghana and Samarkand and set his eyes on North India. His idea was to establish himself in India, strengthen his forces and eventually take back his patrimony in central Asia, however he died before achieving this task.
Here it would be prudent to discuss what Pratap accomplished after his defeat in the Battle of Haldighati as well. Raja Man Singh, the king of Amber, was the commander of the Mughal forces at Haldighati. Even after being defeated at Haldighati, where his army of 3000-4000 Rajputs and allied Bhils (400 men approx.), was defeated by Man Singh who commanded the Imperial Mughal Army roughly 8000-10,000 in numbers, Pratap Singh endured and by the end of his reign, he scored a decisive victory against the Mughals at Dewair in 1582 and took back Western Mewar including Kumbhalgarh, Udaipur and Gogunda through guerilla warfare and even destroyed newly built mosques in these regions in retaliation. He died in 1597.
After his death, his son Maharana Amar Singh I (r. 1597-1620) assumed the Throne and followed his father's policy of resisting Mughal overlordship. Amar Singh continued to resist the Mughals and it was clear that he could not be taken in a battle, so Mewar was devastated financially and in manpower due to the policy of Shah Jahan (son of Jahangir, Jahangir had become Emperor in 1605 after Akbar's death) , to scorch the lands of Mewar and make it incapable of supporting the efforts of Amar Singh. Finally, in 1615, Amar Singh submitted to the Mughals. Mewar including Chittor was assigned to him as Watan Jagir or hereditary patrimony. He secured a favourable peace treaty and it was ensured that Mewar would never bend his knee to the Mughal Emperors or serve at his court personally nor would the House of Mewar enter into matrimonial relations with the Mughals.
Apart from these there's a number of other circumstances that the general may find themselves in. The enemy after confidently beating the general could shoot straight for their capital, which would either force the general to give battle or leave him with the prospect of either cutting of the enemy lines of supplies and waiting for them to give battle again or persue him or, in case the general is left with barely enough men to accomplish anything, either give up the capital and take either routes described above, or sue for peace. This scenario would be a result of error on part of the enemy however.
The enemy could also not be this obliging, meaning they could divide their forces, into a smaller contingent, strong enough to continue persuing the retreating or routing forces, while continuing on their way to the capital or simply follow the enemy general and meet them in the next field of battle.
Either way the situation of a general after losing a battle is dangerous. Especially if the battle is decisive. Keep in mind, in India, such battles weren't usually what decided the outcomes of wars, since such battles would form a fraction of the military history of medieval India. While many a war were decided by a decisive battle, this wasn't the common trend of Warfare in the period. The bulk of warfare and military encounters in this period revolved around maneuvers, sieges, short engagements and ultimately making the war untenable for an enemy. This is what many generals tried to do during the Deccan Wars in which hundreds of forts would change hands between the Mughals and Marathas many times over. Maintaining reserves and harnessing the ability to mobilise reserves is a life saver in these circumstances. It's also important that the general not get killed or captured during the rout or retreat, since it could be equal to ending the war effort. It is for this reason, that successful generals, such as Babur or Akbar etc. Usually commanded from the rear or centre.
I would recommend reading the following books which I have found quite useful in understanding medieval military strategy and tactics.
"Military history of India" by Sir Jadunath Sarkar
"Thirty Decisive Battle of Jaipur" by Narendra Singh (Rao Bahadur.)