Programming Technique: How to create a simple card game

Posted by Shyam on Stack Overflow See other posts from Stack Overflow or by Shyam
Published on 2010-04-14T21:52:57Z Indexed on 2010/04/14 22:13 UTC
Read the original article Hit count: 380

Hi,

As I am learning the Ruby language, I am getting closer to actual programming. So I was thinking of creating a simple card game. My question isn't Ruby orientated, but I do know want to learn how to solve this problem with a genuine OOP approach. In my card game I want to have four players. Using a standard deck with 52 cards, no jokers/wildcards. In the game I won't use the Ace as a dual card, it is always the highest card.

So, the programming problems I wonder about are the following:

  1. How can I sort/randomize the deck of cards? There are four types, each having 13 values. Eventually there can be only unique values, so picking random values could generate duplicates.

  2. How can I implement a simple AI? As there are tons of card games, someone would have figured this part out already, so references would be great.

I am a truly Ruby nuby, and my goal here is to learn to solve problems, so pseudo code would be great, just to understand how to solve the problem programmatically. I apologize for my grammar and writing style if it's unclear, for it is not my native language.

Also pointers to sites where such challenges are explained, would be a great resource!

Thank you for your comments, answers and feedback!

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about ruby