The Two Generals’ Problem


Comments • 3 040

  • Tom Scott
    Tom Scott   6 months back

    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

    • Caleb Gonsalves
      Caleb Gonsalves  2 weeks back

      We in India have an option to call the restaurant and the delivery driver so that solves the two generals problem here...

    • deltor 12
      deltor 12  4 weeks back

      Fire signals to show u received the message. So what can be the fire signal for computers

    • Артем
      Артем  1 months back

      Also if you are a real computer nerd than you surely must know that the weakest point of a system is a human being. So storing all passwords in one place under one probably not complicated master password since you probably will enter quiet often - is the dumbest thing to do!

    • Clockwork Games
      Clockwork Games  1 months back

      Use just eat not deliveroo - its more ethical as well as this event

    • Ana Paula
      Ana Paula  1 months back

      Tom Scott send 10 messengers or more so that the probabilities are in your favor and then attack, it’s likely that at least one will make it, checkmate mate

  • Sebastian Nordlund
    Sebastian Nordlund  2 days back

    Same thing happened with a bus ticket app, where I live.

    • Martin Zhang
      Martin Zhang  2 days back

      Wait Britain has Deliveroo?!?!?!! I thought it was just an Aussie thing since we have kangaroos

      • DogeScape
        DogeScape  3 days back

        For The Valley question just send 1 from each side then they return from each side confirming a time to attack at

        • Карасик Ерохин

          What a moron will pay for some obscure new password manager when you can use old and trusted keepassxc?

          • Jason Sun
            Jason Sun  1 weeks back

            Two messengers meet in the valley, signs a note saying order was received, then comes back with a note with both messengers signature. PROBLEM SOLVED.

            • TheRassad
              TheRassad  6 days back

              What if after signing, GenB's messenger is killed? Then GenB receives no confirmation and wont attack. GenA dies...

          • Rui Pratz
            Rui Pratz  1 weeks back

            Just use smoke signals

            • St0ner1995
              St0ner1995  2 weeks back

              a possible "solution" to the two generals problem. send 3 messages with an identical identifier (so that it's clear that it is the same message), respond to each individual message with it's own acknowledge, respond to those individual responses with an acknowledge and as long as those are all done at slightly different intervals (say a few milliseconds for the app, or 15 minutes for the problem itself), the chances of all 3 failing are greatly reduced, though not zero

              • samkachar
                samkachar  2 weeks back

                Not bad videos, but having been a computer engineer for many many years now I can say there are many many times huge issues caused by a single person.

                • Junior
                  Junior  2 weeks back

                  I think the solution to it would be that both of the generals know that the only logical thing to do would be to attack immediately right when they pop into existence, since without doing that it would be unsolvable.

                  • jrw
                    jrw  2 weeks back

                    Why would anyone order food to their home when they can cook a good meal in half the time for 1/10th the cost?

                    • Sdsdfdu
                      Sdsdfdu  2 weeks back

                      "a single human error is never the root cause"

                      Didn't Cloudflare's servers break all because of one single regular expression?

                      • Chapi
                        Chapi  2 weeks back

                        Still company's fault for not catching the faulty regex before going into production (code reviews, stress tests, etc)

                    • Stanley Wilcox
                      Stanley Wilcox  2 weeks back

                      My solution which is dumb but would probably work. When each general thinks they’ve received a lot of acknowledgments, say 7 or 8, they just go.

                      • tristan 123455
                        tristan 123455  2 weeks back

                        Why did I read the title as genitals lmao...

                        • Thomas Birtles
                          Thomas Birtles  2 weeks back

                          I’d just send a messenger to the other general, and tell him to send a messenger at a specific time to confirm the time to attack, then both parties would send a messenger.

                          • 007 Dragon
                            007 Dragon  2 weeks back

                            I'm not sure if I understand you correctly, but how would General B sending a messenger at a time specified by General A help? When the messenger sent by General B arrives on time exactly as General A expected, General B still wouldn't know if the messenger got through. This is a problem because at this moment, General B does not know whether General A knows that General B knows what time to attack. IF General A does not know that General B knows what time to attack, General A will not attack at the planned time. P.s. it also does not help to send both messengers at the same time, as one of them will not have any new useful information to pass on / transmit. Sorry if this was confusing, feel free to clarify your idea if I misunderstood it:)

                        • Jason Gilliland
                          Jason Gilliland  2 weeks back

                          The real problem is that you need at least 5 more armies or you'll never conquer Byzantium!

                          • Ewan Biesinger
                            Ewan Biesinger  2 weeks back

                            What if they need the messenger to come back so they know that the message has received

                            • Anirudh Panguluri
                              Anirudh Panguluri  3 weeks back

                              Says certain delivery app in beginning just a couple seconds later shows news articles accusing deliveroo of unethical practices.

                              • Nate Youmans
                                Nate Youmans  3 weeks back

                                Could army A send two messengers over then at the halfway point, one of them turn back to give army A the all-clear, while the other messenger delivers the message?

                                • Desu Vult
                                  Desu Vult  3 weeks back

                                  A. Send a message announcing a time of attack and ask for them to send a messenger back as proof
                                  B. Sends a message back saying that they've read the message
                                  A. Send a message announcing that the decision is final and to send a messenger back as proof, but this time without expecting a response.
                                  If you get a message back, then you just attack at the determined time
                                  A and B are the 2 generals

                                  • Kuriii
                                    Kuriii  3 weeks back

                                    Just send three, if one makes it, the B sends another back, if that one makes it the other sends one back. Then they know they both recieved it and the time is right.

                                    • Vikrant Panday
                                      Vikrant Panday  3 weeks back

                                      Well I mean if you have three acknowledgements I think it's fair to assume the other got the message.

                                      If A send B a message then A wont know B got the message but if they did and sent an acknowledgment back then A got the message but B doesn't know that. So now both A and B know to go at 8 since As the one that made the message and also received an acknowledgment and B got the message and sent it back but even if they didn't know A got it, A still was the one that made the time so they'd go anyway. Just to be safe, A can send another acknowledgment and if B gets it, they'll know both sides are going to go at 8.

                                      • Yoovie
                                        Yoovie  3 weeks back

                                        Mans looks like the hobbit

                                        • ChokeNation
                                          ChokeNation  3 weeks back

                                          what about quantum entaglement? uwu

                                          • Angus Campbell
                                            Angus Campbell  3 weeks back

                                            Smoke. Done.

                                            • nikoladd
                                              nikoladd  3 weeks back

                                              Here's a computer science suggestion: Use transactional promise driven model and thus make your confirmations explicit. In the same way actual payments work.(i.e. reserve and confirm) While the theoretical problem has no guaranteed solution the practical problem does have reasonably guaranteed solutions and that app was poorly designed.

                                              • Viking Ninja
                                                Viking Ninja  3 weeks back

                                                That example doesn't seem to work because they would just need A to tell B 8pm, B acknowledges, then A acknowledges. Both armys know the other knows to attack at 8pm.

                                                • Michael Betts
                                                  Michael Betts  3 weeks back

                                                  What if A's acknowledgement never gets to B. B doesn't attack because it wasn't acknowledged, and A attacks because it was acknowledged. The problem is not knowing the time. It is that there is no way for both parties to be 100% certain that the other party is certain, and will attack. One "solution" (stuff like TCP) is A sends B an initial message repeatedly until it receives an acknowledgement, and B then starts sending acknowledgements to A, until A's response is received. Every time A receives a return message from B it responds that it received the acknowledgement. B knows that the chain is over with the final message, and A knows that it is over when it stops receiving acknowledgements from B, but this could also happen if every acknowledgement messenger from B was killed. In the real world it is unlikely that every messenger from B would be "killed" via some random chance and not some detectable error in the connection, but it could happen if something like a microwave being turned on interferes with a wireless connection, and A is programmes to think it can close the communication after 5 seconds without a response, and other traffic is still getting through.

                                              • Konstantin Führ
                                                Konstantin Führ  3 weeks back

                                                I actually came up with a better solution : Dont attack and dont make war at all :D.

                                                • Wreck-It Rolfe
                                                  Wreck-It Rolfe  3 weeks back

                                                  Imagine paying again after it's said you've already paid.

                                                  • T C
                                                    T C  3 weeks back

                                                    dont show up with two armies, there done.

                                                    • Luner Link
                                                      Luner Link  3 weeks back

                                                      just send 1 person from each general at the same time

                                                      • Aoba Senpai
                                                        Aoba Senpai  3 weeks back

                                                        what if they walk to the castle?
                                                        the other side will see them and walk aswell

                                                        • X.Illuminati.XGamer Productions

                                                          Possible solution to the Two General Problem.

                                                          One general sends two messengers to the other general. One messenger stays back before it passes the castle, and the other messenger passes the castle. The messenger that stayed back will watch the other messenger pass the castle, and will be able to tell if the messenger passing the castle has been killed or has safely passed the castle.
                                                          The messenger that passed the castle would have a time for the generals to attack. The messenger that watched would report back to the general who had sent the two.

                                                          • WalrusWarlord
                                                            WalrusWarlord  3 weeks back

                                                            Have both go at the same time, and meet in the center, thus letting them both confirm a time, and success

                                                            • Michael Betts
                                                              Michael Betts  3 weeks back

                                                              And then one gets killed walking back and the other doesn't see it. Also that isn't solving the two generals problem, because it's a computer science problem, and so there is no middle, the castle represents anytuing with a non 100% success rate, like a wireless connection between two computers, that could be broken temporarily by noise from something else, like a microwave for example.

                                                          • Like a Bossk 627
                                                            Like a Bossk 627  3 weeks back

                                                            Can we get an f for our fallen messengers

                                                            • D Parker
                                                              D Parker  3 weeks back

                                                              I was working at a burger restaurant at the time that this issue was happening. 7 drivers arrived with the request for the same meal. You were smart for recognizing this issue initially and ordering one order

                                                              • Catriona
                                                                Catriona  3 weeks back

                                                                Best solution: Ignore the generals and go to the local pub for some food. :P

                                                                • Combine Echo
                                                                  Combine Echo  4 weeks back

                                                                  Morse code via smoke

                                                                  • Jesus From Hyrule
                                                                    Jesus From Hyrule  4 weeks back

                                                                    I what if u send someone with one person behind and another behind them etc. so that when one gets confirmation they can give the army info right before the others get to The Valley ? I can’t quite explain

                                                                    • Konstantin Führ
                                                                      Konstantin Führ  4 weeks back

                                                                      Solution for the problem is : arrange a certain time /sun stand ( other certain events that are global and recognizable to both armies ) and trust ;).

                                                                      • Wood Kidneys
                                                                        Wood Kidneys  4 weeks back

                                                                        Realistically, couldn’t the other general just fire off a cannon or two in acknowledgement to the letter? I understand I am ignoring the computer science portion of this, but I came here for generals and armies and I will leave on those terms.

                                                                        • InfinityBoss
                                                                          InfinityBoss  4 weeks back

                                                                          Possible solution: One general could send a letter saying what time to attack. It would also say to shoot a flaming arrow in the air if they got the message and if they agree. If one general sees the arrow then the other would also shoot an arrow signaling that they both agree to attack at a specific time.

                                                                          • OneObjective
                                                                            OneObjective  3 weeks back

                                                                            The problem operates under the assumption that the two armies cannot actually see eachother

                                                                        • Random Ashe
                                                                          Random Ashe  4 weeks back

                                                                          Surely after 300 messengers confirming it, I don't REALLY need to confirm the 301st.

                                                                          • William Klueg
                                                                            William Klueg  4 weeks back

                                                                            The two generals problem might be solved by sending a letter every day for a thousand days that says "Once every day for the next one thousand days (more or less depending on how arbitrarily difficult the valley is to pass) send a letter in confirmation of this letter. Mark down instances of letters getting through in your correspondence. On a specific date (at least 1,000 days in the future) we will attack, pending your confirmation."
                                                                            If it is reasonably possible for a letter to get through the dangerous valley this will work. If it is not then no coordinated attack is possible and no attack will take place.

                                                                            • Kyle
                                                                              Kyle  4 weeks back

                                                                              I was like signal fires

                                                                              • E030E03
                                                                                E030E03  4 weeks back

                                                                                Using flags in the general problem is badically using quantum entanglement

                                                                                • Ay lmoa
                                                                                  Ay lmoa  4 weeks back

                                                                                  ...There is castle in the middle of the valley... *Sun Tzu left the group*

                                                                                  • canis pugnator
                                                                                    canis pugnator  4 weeks back

                                                                                    Could the general write we will attack at 12pm light a fire If you received it or we will not attack