pygame is
Simple DirectMedia Layer is
Site Swing

Canasta - 0.2

Peter Frase (pefrase)



A computer implementation of the game of Canasta. Can be played in single-player mode, or by multiple players over the Internet. Requires Twisted in addition to python+pygame, but the Windows executable should work out of the box without any additional installs.

I'm a novice at Python, and this is my first attempt at writing a game with it. Canasta is mostly awesome, to me, because of its social aspects, so this program focuses heavily on the multiplayer element. You can start a game and have other players connect to you over the internet, as long as you have an accessible IP address and an open port. A chat window is provided throughout the game for players to communicate with each other.

A one-player game is available as well, although the computer opponents are still in a fairly rudimentary state.

If you don't know how to play Canasta, a Google search will turn up some good explanations. When you start the game, you can hit F1 to see a brief explanation of the controls. There is also a manual included in the form of a text file.


Version 0.2, now twice as good as 0.1!

Bug fixes:
-Passing with no cards left in the draw pile caused the server to hang
-Getting all four red threes would show up as 8 red threes on the end-round scoreboard
-"freeze on initial discard" option did not work
-Resizing the window on the main menu/assignment screens left black bars (resizing now disabled prior to game start).
-Crashed on ctrl-t (obsolete key binding)

Gameplay changes:
-Turn another card if the first turned is a wild or red three
-Concealed going out is enabled
-Many new gameplay options added for using alternate rules
-Made the interface for staging and melding more complete and consistent.
-Computer now guesses your intended target if you stage a wild card.
-cleaned up obsolete key bindings.
-Cards are now animated when they change locations. The animations can be turned off or made faster/slower through the options menu.

Under the hood:
-Streamlined the melding routine so that staging and melding share the same logic.
-Vastly simplified the melding logic and threw out some horrible code from the very beginning of the project.
-Streamlined the CanastaObjects file and the client and server to eliminate unecessary transport objects.
-Deprecated the special control code for melding wild cards, now using meld/stage command with a special token instead.
-Added more docstrings

-Due to changes in the engine and the network protocol, versions 0.1 and 0.2 are incompatible--you cannot play on an 0.2 server with an 0.1 client, or vice-versa. From version 0.2 onwards, the server will check the client's version and reject incompatible clients. For now, versions must match exactly. Once the game is out of the testing stage, compatibility will be maintained between servers and clients sharing the same major version number.


Home Page:


click to view original size


Canasta - 0.2.5 - Apr 11, 2009
Canasta - 0.2 - Apr 5, 2009
Canasta - 0.1 - Apr 4, 2009 account Comments

If you wish to leave a comment with your account, please sign in first.

March 26, 2012 12:42pm - Lee MacKinnell - nickname: (feldegast)
i tried to run from source and i got hundreds of indent errors
how was the exe created if the source code doesn't even run?
August 5, 2009 12:24am - Peter Frase - nickname: (pefrase)
Thanks for your comments! I will look into the bug you cite when I do the next update. As for the thickness of the stack, I'll have to think about how to implement that. I don't want to have a card counter because it's not true to the physical game (where you don't actually know exactly how many cards are left), but I'll do something to give an indication of the pile's thickness.
May 26, 2009 8:09pm - Chris Lingle - nickname: (chrisl) - 4/5
For being so early in development this game is quite good. The computer opponent/partner make very few mistakes. One big problem I have with the game is that I don't see the thickness of the stack so I often get caught with meldable cards in my hand. Something as simple as a card counter somewhere would be awsome. You need an undo for something that was melded accidentally. I have only had it hang on me a few times and those have all been when I melded all my cards and no discard and I could not undo anything and clicking on the pile did not pass my turn without a discard.
Otherwise this game rocks! Well done. I have not used the networking portion yet but I am sure that will come soon.

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Feb 21, 2017

Jan 31, 2017

Jan 24, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)