A simple implementation of the card game War in C# with slight adjustments...
Needs .NET 5.0 to compile
Rules
- Players each get 26 cards from a shuffled deck.
- Each player reveals the top card of the deck, highest card wins.
- Winning player puts the cards on the bottom of his deck (in this case, in random order).
- If cards are of equal value, instead reveals four cards and compare them in order like step 1.
- First player to get to zero cards loses, if a player has less than four cards when the war is starting, the other player wins by default.
- Special case: If by some freak accident all cards in a war are equal, put them back in random order and go back to battle.
Rules changed slightly from normal War due to the game being too deterministic and easily could go on forever. https://mathoverflow.net/questions/11503/does-war-have-infinite-expected-length
Enjoy