Now that you know the problem, let's see the solution, which is called the Byzantine fault tolerance algorithm. This algorithm involves game theory and math.
The first and foremost practical implementation of the Byzantine fault tolerance algorithm came with the Bitcoin's Proof-of-Work. In this case, the generals are nodes on the Bitcoin network, also known as miners. A network node is a connection point that can receive, create, store, and send data across a network. In other words, nodes are the connected dots that make up a network.
The important concept to grasp here is that these mining nodes start from the assumption that nobody else on the network can be trusted.
The Proof-of-Work algorithm guarantees network consensus even in the presence of Byzantine non-compliant nodes. Let's see how this mechanism works in Bitcoin...