Education STEM

War Card Game in Python…free download

This is a classic War card game implemented in Python for Windows. It’s a very easy game to learn and play. The coding of it was actually more fun and challenging. It’s a 2-player game that even kids can play and is a great time-spender. In this game you’re playing against the CPU.

The game incorporates animation effects, audio and custom graphical user-interface using Python and its PyQt extensions. The codebase is portable to Windows, Linux, and MacOS. However, the version made available here for free is linked as a self-executable (EXE) for Windows.

The full game is downloadable at: https://flyingsalmon.net/downloads/warcardgame.zip

Below is a clip of the game in action on Windows 10.

Overview of the game

Setup: Whole deck of 52 cards. No jokers used.
Points: Highest to lowest values in descending order: A, K, Q, J, 10, 9, 8,…4,3,2. Suits don’t matter.

Number of players: 1 v 1 (the opponent is CPU in this game).
Strategy: Luck!
Objective: Score higher points than your opponent on each draw.

A WAR event occurs when both players have the same points of the played cards.

Ending the WAR: Each player has to play 4 additional cards next to the ‘war’ cards (that caused the tie) on table…the 3 out of 4 cards drawn are face down, only the 4th one is face up and determines who wins the war.

The winner (one who played the card with higher points) takes all the cards on the table including ‘war’ cards (‘war’ cards: the cards that caused the war or tie).

If the 4th cards also equal, the war continues…i.e. each player plays additional 4 cards (leaving all the cards at play on the table) until a winner card is found.
This sequence repeats as long as there’s a WAR and both players have sufficient number of cards to resolve the war (4 cards minimum).

If both players have insufficient cards on hand to resolve a war, but one has more than the other player,
the player with more cards on hand wins the game.

If both players have insufficient cards on hand to resolve a war, and both players have the same amount of cards on hand, game is a tie.

Otherwise, the game continues until a player has 0 cards left on hand, who loses the game.

Game Interface

When you start the game, after you’re familiar with the rules, press New Game button.
The full deck is shuffled and handed out equally to each player (26 cards each) and it enables the Play button. You are playing against the computer (CPU).

Each time you need to draw or play a hand, press Play button.
The cards being currently played are shown on screen…your cards on your left, CPU cards to the right.
The results of each round are shown immediately below your card after a decision is made by the program.

Above the card images, the number of cards each player has on hand are shown every round. It will also show status or notifications as needed.

When the game ends, Play button will be automatically disabled, until you press New Game button.

You can press New Game button anytime and it will abort the current game (even if it’s in progress) and start a new one.

To quit the application anytime, click the ‘x’ icon at top-right corner of the window.

Click Rules button to review the game rules.

More Information: Detailed Wikipedia Reference: War (card game)

Hope you enjoy the free game! No ads, no upsells. No malware. No data collection.

All images and audio used are from public domains from various sources including some of my own art. Some of my go-to sites are: mixkit.co; pexels.com; pixilart.com; openclipart.org



Interested in creating programmable, cool electronic gadgets? Give my newest book on Arduino a try: Hello Arduino!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top