Empty Fort Strategy
In the face of imminent danger, with the main Shu army deployed elsewhere and only a small group of soldiers in Xicheng with him, Zhuge Liang came up with a ploy to hold off the approaching enemy.
Zhuge Liang ordered all the gates to be opened and instructed soldiers disguised as civilians to sweep the roads while he sat on the viewing platform above the gates with two page boys by his side. He put on a calm and composed image by playing his guqin. When the Wei army led by Sima Yi arrived, Sima was surprised by the sight before him and he ordered a retreat after suspecting that there was an ambush inside the city. Zhuge Liang later explained that his strategy was a risky one. It worked because Zhuge Liang had a reputation for being a careful military tactician who hardly took risks, so Sima Yi came to the conclusion that there was certainly an ambush upon seeing Zhuge's relaxed composure.

As a topic of academic study: Christopher Cotton, an economist from the Queen's University, and Chang Liu, a graduate student, used game theory to model the bluffing strategies used in the Chinese military legends of Li Guang and his 100 horsemen (144 BC), and Zhuge Liang and the Empty City (228 AD). In the case of these military legends, the researchers found that bluffing arose naturally as the optimal strategy in each situation. The findings were published under the title 100 Horsemen and the empty city: A game theoretic examination of deception in Chinese military legend in the Journal of Peace Research in 2011.

Historicity: The basis for this story in Romance of the Three Kingdoms is an anecdote shared by one Guo Chong (郭沖) in the early Jin dynasty (266–420). In the fifth century, Pei Songzhi added the anecdote as an annotation to Zhuge Liang's biography in the third-century historical text Sanguozhi. The anecdote is as follows: Zhuge Liang garrisoned at Yangping (陽平; around present-day Hanzhong, Shaanxi) and ordered Wei Yan to lead the troops east. He left behind only 10,000 men to defend Yangping. Sima Yi led 200,000 troops to attack Zhuge Liang and he took a shortcut, bypassing Wei Yan's army and arriving at a place 60 li away from Zhuge Liang's location. Upon inspection, Sima Yi realised that Zhuge Liang's city was weakly defended. Zhuge Liang knew that Sima Yi was near, so he thought of recalling Wei Yan's army back to counter Sima Yi, but it was too late already and his men were worried and terrified. Zhuge Liang remained calm and instructed his men to hide all flags and banners and silence the war drums. He then ordered all the gates to be opened and told his men to sweep and dust the ground. Sima Yi knew that impression that Zhuge Liang was a cautious and prudent man, and he was baffled by the sight before him and suspected that there was an ambush. He then withdrew his troops. The following day, Zhuge Liang clapped his hands, laughed, and told an aide that Sima Yi thought that there was an ambush and had withdrawn. Later, his scouts returned and reported that Sima Yi had indeed retreated. Sima Yi was very upset when he later found out about the ruse.
After adding the anecdote to Zhuge Liang's biography, Pei Songzhi wrote a short commentary as follows: When Zhuge Liang garrisoned at Yangping, Sima Yi was serving as the Area Commander of Jing Province and he was stationed at Wancheng (宛城; present-day Wancheng District, Nanyang, Henan). He only came into confrontation with Zhuge Liang in Guanzhong after Cao Zhen's death (in 231). It was unlikely that the Wei government ordered Sima Yi to lead an army from Wancheng to attack Shu via Xicheng (西城; present-day Ankang, Shaanxi) because there were heavy rains at the time (which obstructed passage). There were no battles fought at Yangping before and after that period of time. Going by Guo Chong's anecdote, if Sima Yi did lead 200,000 troops to attack Zhuge Liang, knew that Zhuge Liang's position was weakly defended, and suspected that there was an ambush, he could have ordered his troops to surround Zhuge Liang's position instead of retreating. Wei Yan's biography mentioned: "Each time Wei Yan followed Zhuge Liang to battle, he would request to command a separate detachment of about 10,000 men and take a different route and rendezvous with Zhuge Liang's main force at Tong Pass. Zhuge Liang rejected the plan, and Wei Yan felt that Zhuge Liang was a coward and complained that his talent was not put to good use." As mentioned in Wei Yan's biography, Zhuge Liang never agreed to allow Wei Yan to command a separate detachment of thousands of troops. If Guo Chong's anecdote was true, how was it possible that Zhuge Liang would allow Wei Yan to lead a larger army ahead while he followed behind with a smaller army? Guo Chong's anecdote was endorsed by the Prince of Fufeng (Sima Jun, a son of Sima Yi). However, the story puts Sima Yi in a negative light, and it does not make sense for a son to approve a story which demeans his father. We can tell that this anecdote is fake after reading the sentence "the Prince of Fufeng endorsed Guo Chong's anecdote".
Evidence from historical sources indicate that Sima Yi was indeed not in Jieting at the time. The Battle of Jieting took place in 228 but Sima Yi's biography in the Book of Jin claimed that in 227, Sima Yi was stationed at Wancheng in the north of Jing Province. He led an army to suppress a rebellion by Meng Da at Xincheng (新城; in present-day northwestern Hubei), and returned to Wancheng after his victory. Later, he went to the imperial capital Luoyang to meet the Wei emperor Cao Rui, who consulted him on some affairs before ordering him to return to Wancheng. Sima Yi only engaged Zhuge Liang in battle after 230.
Yi Zhongtian, a professor from Xiamen University, commented on this incident in his book Pin San Guo (品三国). He pointed out three problems in the story:

Sima Yi did not dare to attack because he feared that there was an ambush inside the fortress. If so, he could have sent recces to scout ahead and check if there was really an ambush.
Romance of the Three Kingdoms provided this description: "(Sima Yi) saw Zhuge Liang sitting at the top of the gates, smiling and playing his guqin and being oblivious to his surroundings." Based on this description, the distance between Sima Yi and Zhuge Liang must have been very short, or else Sima would not have been able to observe Zhuge's actions so clearly. If so, Sima Yi could have ordered an archer to kill Zhuge Liang.
Both Guo Chong's anecdote and Romance of the Three Kingdoms said that Sima Yi's army was superior to Zhuge Liang's in terms of size: Guo Chong's anecdote stated that Sima Yi had 200,000 men while Zhuge Liang had 10,000 men; Romance of the Three Kingdoms mentioned that Sima Yi had 150,000 men while Zhuge Liang had only 2,500 men. If so, Sima Yi could have ordered his troops to surround Zhuge Liang's fortress first, and then wait for an opportunity to attack.

Li Yuan: According to historical sources such as the Old Book of Tang, New Book of Tang and Zizhi Tongjian, Li Yuan, the founding emperor of the Tang dynasty, used a similar strategy in 618 CE in a battle against the Göktürks before he started his rebellion against the Sui dynasty. In early 618, Li Yuan was still a general in the Sui army and was based in Jinyang (晉陽; present-day Taiyuan, Shanxi). When he heard rumours that Emperor Yang of Sui wanted to execute him, he started making preparations for a rebellion against the Sui dynasty to save himself. In May 618, the Göktürks allied with the warlord Liu Wuzhuo to attack the Sui dynasty in order to gain territory. Jinyang became one of their targets.
Around the time, Li Yuan had just arrested Wang Wei (王威) and Gao Junya (高君雅), two officials sent by Emperor Yang to spy on him. He was also still busy plotting his rebellion. Moreover, he was also not prepared for a battle against the Göktürks because of two reasons. Firstly, Göktürk cavalrymen were so powerful that Li Yuan was not confident that his troops could defeat them. Secondly, even if Li Yuan defeated them in battle, he would nonetheless suffer significant losses that would undermine his rebellion against the Sui dynasty.
Li Yuan thus ordered his soldiers to hide in Jinyang and leave the city gates wide open.