The Two Generals’ Problem

23 939
Tom Scott
Tom Scott - 8 months ago
Yes, I had help with the graphics for this series. There's no way I'd have animated that myself! On that note, thanks to Dashlane for sponsoring and helping me hire an animator: their free trial link is
Michael W
Michael W - 4 days ago
The semaphore flags spelled "T O M" ...very clever, and nice attention to detail! ...Well technically they spelled "T M" as the correct signal for "O" requires the flag in the 270° position to be held by the left hand of the signaler. So only one flag should have moved in the transition from "T"(left hand 360°) to "O"(left hand 270°) while the right hand stays at 315° for both. *(All positions relative to observer) However (comma) one could argue there wasn't a signaler in the animation and the flags where held up by crushed American dreams and unicorn tears. Therefore (comma) traditional rules don't apply. Just having a bit of fun tbh... Love your channel!
Ginger Wh ale
Ginger Wh ale - 19 days ago
If general a sent a messenger to general b to say that at 4:30 they would both send a messenger to the middle where the messengers would meet to confirm that they would both attack at 8 then general a and b would know if the other general knew based on if their messenger they sent to the middle said that the other messenger made it
jason haynes
jason haynes - 21 day ago
Such passion
DreamSmasher - 27 days ago
Our phones show us if the message has been received.
James Martin
James Martin - Month ago
For the problem would having the messenger make two trips not suffice because then team a and b now know what the time is and can attack together
Rhys Lewis
Rhys Lewis - Hour ago
‘I was hungry and tired Just like there drivers’
daveys11 - 19 hours ago
I thought the title said “The two genitals problem”
WASDPvP - Day ago
they both meet in the middle
NIXON DIXON - 2 days ago
You look like you have two different haircuts at the same time
M Johnson
M Johnson - 2 days ago
G1: Attack 8pm?
G2: Yes Attack 8pm! Tea tomorrow?
G1: Attack 8pm. Tea at what time tomorrow?
G2: Attack 8pm. Tea at 11am tomorrow?
G1: Attack 8pm. Tea at 11am!
G2: Attack 8pm. Tea at 11am.(At this point G1 and G2 are confirmed for 8pm attack, both generals have read, acknowledged the attack and now are working on other inquiries. "Attack 8pm" is no longer a question but a read receipt from both Generals)
Stu West
Stu West - 2 days ago
As a rule. When money is leaving your pocket, be cautious. If you think there might be a problem, there is and it's rarely in your favor. The computer is your wallets second worst enemy next to a human being.
Biggie Willie
Biggie Willie - 2 days ago
Who old is this dude
M M - 3 days ago
How does my iPhone tell me they’ve seen my message then?
MrShanester117 - 5 days ago
If both sides send a messenger to the middle. Then those two coordinate and go back to their own armies. If they don’t come back, you know they got killed and you didn’t successfully coordinate. If they both come back, you know you have gotten your message across. And you’re time is set. 🤷‍♂️
TheIceBlade - 2 days ago
Ok, but how would one side know the others messenger had successfully made it back without getting killed?
derHutschi - 5 days ago
quite a fewyears ago (when orders to suppliers where sent by fax) there was a box 'tick this if you're sending it again as a copy' sothesupplier could see if they had to place it or just send a confirmation
but computers are always perfect ;-)
Seth Adkins
Seth Adkins - 5 days ago
Couldn't the messenger of general A just come back to the army and confirm that general B got the message?
coopboulton - 5 days ago
It definitely isn't perfect but I think the most effective way for the two generals to communicate with me for the runners to meet at a neutral site in between the two armies camps. So the only risk of a messenger dying is on their return trip to their own Army.
CODE92818 - 6 days ago
San Fernando valley.
singer M
singer M - 6 days ago
What if you send the messenger and instead of having them send an acknowledgment back, you just tell them "If you received the message, move all your troops (as one mass) 1,000 feet to the (insert direction here)"? Wouldn't that be able to work?
FuciMiNaKule - 6 days ago
You are getting hung up on the analogy instead of the actual problem. It's a problem about two computers communicating.
Admiraal Graf Speeツ
Admiraal Graf Speeツ - 6 days ago
This had nothing to do with the generals.
Dyslex Official
Dyslex Official - 7 days ago
This problem is not unsolveable.... message will attack at 8AM send smoke to acknowledge.
FuciMiNaKule - 6 days ago
You are getting hung up on the analogy instead of the actual problem. It's a problem about two computers communicating.
Egon Freeman
Egon Freeman - 7 days ago
Fortunately, there are ways to solve the Two Generals problem by the use of binoculars, smoke signals, or even radio. Similarly, you can solve it in computing by using more than one channel (the other channels may be reserved for emergencies or double-checking for scenarios like this one). Redundancy isn't enough if it shares common choke points, and people tend not to like heterogenous redundancies (because by their very nature they don't fit into the established view/model)... but the truth of the matter is - they work. A simple example of this is having someone call you to confirm the two extra orders. That's not even in IT scope unless they're using VoIP! ;)
Egon Freeman
Egon Freeman - 7 days ago
"A single human error is never the root cause" - option a) the programmer neglected to check for failures; option b) someone bumbled around in the server config and mistakenly wiped part of the firewall configuration for outgoing packets (because why not? it can happen). Both very common issues, I'm afraid. In this particular field, one person's mistake *can* bring the whole system down, if the mistake is big enough.
Toby Chung
Toby Chung - 8 days ago
Wait, is there a problem with Deliveroo? We have it here in Hong Kong, and I hope I'm not doing anything wrong.
Matt Pinkerton
Matt Pinkerton - 8 days ago
Because of this video I avoided a similar problem with uber eats, it said there was a problem ordering and I remembered this video, made sure to check my bank account. Sure enough while Uber said the order wasn't placed, the money was out of my account. 20 minutes later my order arrives, thanks Tom!
Kyle Hart
Kyle Hart - 8 days ago
Dang! After the VPN video, an endorsement from Tom Scott for a sponsor means a lot.
Slav Squirrel!
Slav Squirrel! - 9 days ago
2:12 i’m confused. Why don’t you only need two additional acknowledgment of the acknowledgments and then commence the attack?
Alpem_Warrior - 6 days ago
Because it's always the same: the one that sent the last message does bit know if it arrived.
Isaac Miller
Isaac Miller - 9 days ago
Wait, i'm not a computer person. What do the generals do?
Kuma Bear
Kuma Bear - 9 days ago
How about shooting a flare in the night for confirmation?
smileforthejudge1 - 11 days ago
Dinuk W.
Dinuk W. - 11 days ago
How does the idempotency token solve the two generals problem? The two use cases of avoiding duplicated processing (ordering take-out example) and mutual acknowledgement (two general's problem) are orthoganal. Not sure I quite understood the segue into idempotency.
Dylon Allen
Dylon Allen - 12 days ago
This video just saved me from double paying for an AIRBNB. Thank you!
Alan Forster
Alan Forster - 12 days ago
If the messengers meet in the middle and then go back it would work.
FuciMiNaKule - 6 days ago
That's not how computers operate though.
Chexsum - 13 days ago
i ordered sushi that night
Don Robertson
Don Robertson - 14 days ago
Apple? Oh dear.
Bilbo Fappins
Bilbo Fappins - 14 days ago
Video: "This is a computer science problem"
Comments section: thousands of comments "solving" the problem as if it wasn't
TheVergile - 14 days ago
i know friends like that.
no amount of messages going back and fourth agreeing on time and place can guarantee theyll actually on time. or at all
Mike M
Mike M - 14 days ago
Dashlane- fine for storing complete passwords. But banks often want selected characters from the password- and additional checks. No help there. If I am going to pay for a password manager it has to do the whole thing.
iSquared - 15 days ago
What happens if I want to actually make a repeat identical order, within a few minutes, on the same card?
FuciMiNaKule - 6 days ago
Why would you though? Just put everything into one order. Also this doesn't prevent that. If you make a new order, it won't be identical even if the items are. You will get a new idempotency key by making a new order. This only affets if you get a "order failed" message even if the server has recieved an order, by failing to deliver a confirmation. It would give you a "try again" option, which would send the exact same order with the exact same idempotency key. The server can then disregard that order because it knows you hit "try again" even though the server recieved the order, which can only mean you didn't get a proper confirmation message.
Colin Eriksen
Colin Eriksen - 16 days ago
A solution to the two generals problem: Have general A send general B a message saying “attack in 100 messages from now. When you reply write 99 messages. After waiting the amount of time required for a message to get through to you and back I will send another message. You will do the same. Always include these same instructions no matter what and I will do likewise. If you have not received a reply to your latest ten messages, restart the timer and attack in 100 messages and I will do the same.” Thus both generals will not attack unless:
a) both generals know what to do
b) both generals know when to attack
Windsor Pamorca
Windsor Pamorca - 16 days ago
I came expecting a fun animated problem, i left learning how to code Minecraft from scratch
Cant think of name Yeah
Cant think of name Yeah - 16 days ago
Easy make the side that gets the message start T posing ass a symbol so that the people on the other side can see the message has been sent l even from miles away.
QuantumGaming - 16 days ago
If it was an actual physical group of armies. I’d use audio signals with my marching band, unless I was aiming for stealth.
Jeremy Dibble
Jeremy Dibble - 16 days ago
Each genral sends a messenger cause there both gona be thinking about it, so one should decide to keep one in the middle, about half way, so when the other sends the message there is some one waiting, then they both return to their respective generals telling each that the message and acknowledgement has happened
Pol Roca
Pol Roca - 16 days ago
Happened the same with Phillip’s web shop. Bought 3 times a 200$ order. They gave my money back, tho.
buck rogers
buck rogers - 16 days ago
red general just take you entire army acriss to the other army and get the plan sorted
Andrew Deresh
Andrew Deresh - 16 days ago
Best explanation ever
Kayla Goodwin
Kayla Goodwin - 17 days ago
There is a solution. A tells the messenger to send a time of attack to B. Say it is 0900 when the messenger is sent off and it takes 2 hours to get to the other side of the valley. The time of attack would be later than 1300 so if the messenger didn't come back the attack would be called off. When messenger A would go back, a person from army B would go with them but only to the castle to ensure messenger A would get back safely and person B would get back safely without the risk of being caught because they both left the castle at the same time. This way if the people in the castle find messenger A they will also find person B at the same time so both armies will know not to attack because neither of them got back. Even if messenger A never gets to army B, neither will attack because army A will assume the message didn't get through and army B wouldn't have received the message so they wouldn't have a time of attack. All they have to do is agree that they would not attack until both people are back, which will be told to army B by messenger A.
Or they could go around the valley because it's not 3 dimensional, unlike the depiction in the video.
Or they could just organise the attack time before they seperate because they obviously were in contact with each other at some point because they both knew to be on seperate sides of the valley.
Or they could send every person from army A to army B one by one and all attack together from the same side of the valley, or attack from a third point such as the side of the valley.
FuciMiNaKule - 6 days ago
You are getting hung up on the analogy instead of the actual problem. It's a problem about two computers communicating.
Timofey Bednarchuk
Timofey Bednarchuk - 17 days ago
Smoke signals
Entropic0 - 17 days ago
Doesn't it depend on the time of travel between the two camps, and not just the odds of getting a message through? Suppose a battle will last 10 hours yet the distance to send a messenger is 1 hour. This means at worst the reinforcements would arrive 2 hours late if they arrive as a result of a messenger letting them know the battle has begun. If they can see the castle, they can see the attack happening and at most would be 1 hour late. It would probably be easier to get a messenger through if an assault were happening, too. Also, why send only 1 messenger? Why not send 50? Why not attack the castle, and, knowing the time for reinforcements is 2 hours max, abandon the battle if reinforcements haven't arrived in 2 hours? This problem with the constraints that it has is technically unsolvable, but I think it's a better example of how false dichotomies lead to erroneous conclusions. You assume either a messenger makes it through or not. You assume either an army attacks and losses or attacks and wins when in reality there is a gradient of options. You assume either one messenger is sent or zero (when they could send multiple and that changes the odds of getting through). Etc, etc. If you knew the travel time between the camps, sent multiple messengers while attacking, and backed-off if reinforcements didn't arrive in the expected time-period, the odds of losing would be very minuscule.
FuciMiNaKule - 6 days ago
You are getting hung up on the analogy instead of the actual problem. It's not a problem in military strategy, it's a problem about two computers communicating.
milspire - 17 days ago
Have you tried negotiating with the lord of the castle? Was peace even an option?
goober - 17 days ago
So this sounds likes it's solved with a quantum computer quite easily....
Jamal Freeman
Jamal Freeman - 17 days ago
One issue with the two generals problem I see is that it is completely fine for just three messengers. After the third messenger general A knows B got the message, and general B knows this has been acknowledged.
SimulationEvolve - 17 days ago
"A single human error is never the root cause"

I would dare to disagree.
Marauding Umbreon
Marauding Umbreon - 17 days ago
This is known as the Byzantine General problem, not the 2 Generals problem.
BaraZulu - 17 days ago
This guy looks older and young as hell at the same time.
SirpentPlayz - 18 days ago
Calling it right now, 2 scouts meet in the middle
CE 170 Chem Lab
CE 170 Chem Lab - 18 days ago
This isn't foolproof. I order a pizza; as I hang up, my friend shows up and I immediately call back and order another pizza.
Edit: Good vid, though. I learned about the two generals problem, an interesting thing I did not know before. Thank you.
FuciMiNaKule - 6 days ago
Well, if you are physically calling then this problem doesn't exist because humans can ask if you're making a second order. However if you were to order something online, "hanging up" would be akin to confirming the order and then making a new one, which would give you a new idempotency key. The problem arose when you sent an order, and instead you got an "order failed" message even though it hasn't failed, only the confirmation of the order failed. That gives you a "try again", which sends the EXACT SAME ORDER (not just same items, the exact order that has the same idempotency key), which then the server can disregard because sending the exact same order, including the same idempotency key, can only mean that you hit "try again".
Impatient Samurai
Impatient Samurai - 18 days ago
This seems like the battle of nagashino. Oda and Tokugawa forces were attacked by massive takeda forces. The catch was Tokugawa forces were in a castle being besieged by takeda forces. Oda sent a messenger with something along the lines of; this time the army attacks, light fires or raise flags when this is received
OGtuber - 18 days ago
I only like videos i want to save but here's a comment. Great vid!
ProductBasement - 18 days ago
I love the Two Generals Problem. It's a plausible but funny story that illustrates both a problem for computer scientists and everyone else, and it leads to the counterintuitive conclusion that communication is one of those delightful things that work only in practice: in theory, it's impossible
JK - 18 days ago
what happens if they both meet in the valley? agree a time there and relay it back knowing each are both alive
Irwan Effendi
Irwan Effendi - 19 days ago
General A sends a message:
hey B, we are sending troops at 8. please send me confirmation number one and I will send you receipt number one. We will try to confirm and receive three times but regardless of success, after you get receipt number one, it is a GO.
General B sends a message:
hey A, this is confirmation number one, please send me receipt number one
General A sends a message:
hey B, this is receipt number one, please send me confirmation number two and I will send you receipt number two
General B sends a message:
hey A, this is confirmation number two, please send me receipt number two
time's up
they both attack
problem solved.
Milo Legends
Milo Legends - 19 days ago
Its a large, open area ... they can just see that the other army is moving and start to move as well...?
An Meme
An Meme - 19 days ago
Big brain
Ashes527 - 19 days ago
What if they sent two messengers through the valley? One would keep going and one would come back to confirm that they saw the other make it? I know this doesn’t really work with computers but hey it might work in that analogy.
FuciMiNaKule - 6 days ago
The analogy doesn't need solving dude, the computer problem does. Otherwise you can just tell the messenger to walk around the castle far enough not to get attacked.
Shyam Buddh
Shyam Buddh - 17 days ago
I was thinking of the same, and I have come to the conclusion that it's sort of cheating although not really because the assumptions never say that the messengers can't do that. But they also don't say that they can.
Google Doxx'd me Bruh
Google Doxx'd me Bruh - 19 days ago
What idiot military sends two separate forces to attack a castle with no communication.
FlowJo - 19 days ago
I can’t sit through this blabbering. Is there a solution or not?
Corbin Tubo
Corbin Tubo - 19 days ago
Why doesnt general A send a messenger to general B proposing a time, then general As guy just comes bwck and says that it has been agreed to
sldfnslkxxlk - 19 days ago
Did you even watch the video??? 1:52 The whole point of the problem is that the messenger to general B may not get there, and the messenger going back to general A might not get there either. So B might agree to the time, then the messenger dies on the way back and A never knows it's been agreed to (and therefore doesn't attack). B does not know the messenger didn't make it back so goes ahead with the attack, but loses because A isn't attacking.
Swampfire - 19 days ago
Couldn’t this also be considered a Type 1 error? Taking stat and com sci with the same teacher at same time and there are a suprise amount of ways to compare
RexusprimeIX - 19 days ago
Just do the conformation thing 5 times, and by the fifth time it doesn't matter if that confirmation was received or not, both Generals know that the original request and acknowledgment have been received. There, I easily fixed your problem.
FuciMiNaKule - 6 days ago
How do they know? A sends a messenger, B sends one back, A sends one back, B sends one back, A sends one back. Assuming all survive (which you can't), B is the one who recieves the final one. How does A know they got him? If A assumes they didn't, they conclude that B might think A didn't get their message and might decide not to attack. In practice, yes, redundancy and multiple messages do work, but the problem is that there can never be a situation in which both generals know the other will 100% attack, i.e. each computer is sure the other has recieved all their messages.
Freelance Generalist
Freelance Generalist - 19 days ago
Cool story bro... wow who cares
Fin Arfin
Fin Arfin - 19 days ago
Ez. Use homing pigeons or the beacon like in LOTR as acknowledgment. Problem solved.
7\ Reed 7\
7\ Reed 7\ - 19 days ago
they could send the message and the courier could come back and confirm it
Jules B
Jules B - 19 days ago
Why isn't the castle build on the high ground this is so stupid.
Shoot The Moon
Shoot The Moon - 20 days ago
Speak American you SOB
Robert Goodman
Robert Goodman - 20 days ago
I love the way this ends with an ad that's educational.
TigerTrainerXD - 20 days ago
Send a messenger over, and have that same messenger come back. If they don't, just send another messenger with the exact same orders. Seems simple enough.
Shyam Buddh
Shyam Buddh - 17 days ago
But the other army doesn't know whether the messenger returned to the original army they came from. Hence, their attack may fail.
sidg11 - 20 days ago
mm The solution you provide here doesn't actually solve the 2 generals problem though does it?
Edwin Levi
Edwin Levi - 20 days ago
Like when you press print hella times and they all print at once
TwizzyFizzy - 20 days ago
Why not just have them light up a fire with black smoke to indicate messege was received?
FuciMiNaKule - 6 days ago
Because that's not how computers work.
Memino3 G
Memino3 G - 20 days ago
The messengers meet at either the left or the right of the castle. Once this is done both return to their generals with the information learned.
aznfratboy1 - 20 days ago
The lesson: Takeaway is for losers. Either cook the food yourself or go to the restaurant and dine in like a human being.
Carlos Espindola
Carlos Espindola - 19 days ago
aznfratboy1 Its a computer science video... its meant to be taken literally.. thats it
aznfratboy1 - 19 days ago
That's actually exactly the lesson. Learn to read between the lines.
Carlos Espindola
Carlos Espindola - 19 days ago
aznfratboy1 thats not the lesson....
Brenton Miller
Brenton Miller - 20 days ago
You look like you have glasses on and yet there are no glasses on your face
Next videos