There is a game known as the Prisoner's Dilemma. The dilemma is very simple. You have two people who can each make one of two choices. The standard presentation is that you have two thieves who have been caught. The thieves are kept separate, and are interrogated. Confess, and turn in your partner, say the jailers, and we will let you off. However, if both prisoners confess separately, they both stay in jail. If both prisoners stay silent, typically the result is that both thieves serve less time than if the other one had ratted them out. Thus the dilemma. If you say silent and your partner confesses, you are the one who stays in prison. If you both confess, you both stay in jail. If you screw your partner, you get off scot free. The Prisoner's Dilemma is one of the textbook examples of a field known as Game Theory.
Game Theory was invented by John von Neumann and Oskar Morgenstern, but it was really fleshed out by Merrill Flood and Melvin Dresher who were working for the RAND Corporation. The work of the RAND Corporation was primarily in the field of Operations Research. This field emerged during World War II, as the Allies sought solutions to problems such as the best way to search for U-Boats. Game Theory is one of the tools of Operations Research, wherein you can use logic and mathematics to calculate the optimum strategy for a given "game" or situation when you know the payoff, and you think you can reasonably predict what the other guy is going to do. A method of making this more informative is to repeat the game many many times in simulation and then average the results. Thus we get the Iterated Prisoner's Dilemma. Each prisoner now has the additional information of what the other guy did before. Patterns tend to emerge in these iterated games, such as Tit-for-Tat, wherein you stay silent, unless the other guy ratted you out last time, and then you punish him by confessing this time.
The Iterated Prisoner's Dilemma is sometimes claimed to be foundational in ethics. The idea here is to try to found ethics on a supposedly objective basis involving nothing but logic and probability. Hah! I wouldn't say that you can't learn anything from the Prisoner's Dilemma, but you definitely cannot found ethics upon such a pitiful foundation. The biggest problem is that you really have to come to the game knowing right from wrong. You cannot deduce it from the game because you have to know in advance which outcomes are preferable and why. Game Theory just tells you the the likelihood of certain outcomes given certain assumptions. Plus we can't forget that the game makes a lot of simplifying assumptions. If you look at the Stanford Encyclopedia of Philosophy page on the Prisoner's Dilemma, you can see that many variants of the Prisoner's Dilemma have been created. But each one shares the same kinds of limitations. For example, there isn't any background knowledge like my partner is my brother, or I smuggled in a knife and I'm going to shank the interrogator and escape. Game Theory is used a lot in military planning, but the problem is that people are both predictable and unpredictable. Victory is often achieved by surprise, and surprise is an event that occurs in the mind of an enemy commander. Game Theory probably helps you be surprised.
However, this is all a little abstract. If you want to see an Iterated Prisoner's Dilemma, just watch this clip from a British game show. You can see exactly how it goes down, but now there are real people, with real emotions and motivations playing the game.