Questions tagged [playing-cards]

Programming questions involving digitally-represented playing cards. This includes issues like representing cards and decks in data structures, user interfaces for manipulating cards in a virtual fashion, implementing correct algorithmic shuffling, and using cryptographically secure protocols to exchange cards over a network. Please browse this tag with your target language (e.g. [java] [playing-cards]) to see if your question has been asked before!

291 questions
71
votes
2 answers

How to initialize a static array?

I have seen different approaches to define a static array in Java. Either: String[] suit = new String[] { "spades", "hearts", "diamonds", "clubs" }; ...or only String[] suit = { "spades", "hearts", "diamonds", "clubs" …
Jeremy S.
  • 5,895
  • 12
  • 45
  • 62
40
votes
9 answers

7 Card Poker Hand Evaluator

Does anyone know a fast algorithm for evaluating 7 card poker hands? Something which is more efficient than simply brute-force checking a every 21 5-card combination of hands from a set of 7. Cheers, Pete
user130076
18
votes
6 answers

Cryptography for P2P card game

I'm considering writing a computer adaptation of a semi-popular card game. I'd like to make it function without a central server, and I'm trying to come up with a scheme that will make cheating impossible without having to trust the client. The…
so12311
  • 3,823
  • 24
  • 35
16
votes
5 answers

Python: 'object in list' checks and '__cmp__' overflow

this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site. I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from…
Ulquiomaru
  • 726
  • 6
  • 9
16
votes
8 answers

Card Shuffling in C#

I am trying to write a code for a project that lists the contents of a deck of cards, asks how much times the person wants to shuffle the deck, and then shuffles them. It has to use a method to create two random integers using the System.Random…
Jeff
13
votes
5 answers

How to really shuffle a deck of cards

When I need to shuffle a deck of poker cards in Java/Android, I use Collections.shuffle(List list), of course. I've ever been doing this and the results seemed acceptable. But they aren't. As outlined in this paper, there are 52! possible unique…
caw
  • 29,212
  • 58
  • 168
  • 279
9
votes
2 answers

Game architecture and design strategy for a multiplayer card game

I am relatively new to game development so I decided I wanted to create a hobby project from scratch for both experience and entertainment. The specific game is similar to poker known as Three Card Brag. The game is played in the movie Lock, Stock…
John Rasch
  • 57,880
  • 19
  • 101
  • 136
9
votes
3 answers

What is the optimal winning strategy for this modified blackjack game?

Questions Is there a best value to stay on so that I win the greatest percentage of games possible? If so, what is it? Edit: Is there an exact probability of winning that can be calculated for a given limit, independent of whatever the opponent…
hobodave
  • 27,277
  • 4
  • 69
  • 77
9
votes
3 answers

Correctly using LINQ to shuffle a deck

I am attempting to write a simple card game. In an effort to come up with a good shuffling algorithm I came across Jeff Atwood's post on Coding Horror. However When I view the contents of the object after calling the Constructor they are not…
jth41
  • 3,542
  • 8
  • 50
  • 105
8
votes
3 answers

Adding constant fields to F# discriminated unions

Is it possible to add constant field values to F# discriminated unions? Can I do something like this? type Suit | Clubs("C") | Diamonds("D") | Hearts("H") | Spades("S") with override this.ToString() = // print out the letter…
Ralph
  • 29,142
  • 31
  • 124
  • 261
7
votes
1 answer

What's the best way to enumerate permutations of deck of cards?

I'm looking to make a function that would assign a value to a specific shuffle of cards. The function has to be bijective. The deck has 52 cards so there are 52! different shuffles, therefore the domain is the set of all permutations of 52 cards,…
Davo
  • 444
  • 3
  • 10
7
votes
1 answer

Javascript- Lodash shuffle vs. Math.Random()

I'm in the process of coding a simple BlackJack game in Javascript. So far, I have an array like this: var deckArray = [ "card1", "card2",...,"card52" ] I have a "deal" function set up like this: var deal = function(){ var card =…
KnowledgeMC
  • 93
  • 1
  • 2
  • 7
7
votes
4 answers

Is my method working effectively?

I'm writing a code for a deck of cards which shuffles the deck of cards. I tested the code but I don't really know if it's actually doing what it's supposed to be doing correctly? What do you think? This is the code for the shuffle method: public…
Panthy
  • 1,475
  • 2
  • 18
  • 26
6
votes
6 answers

wxPython or pygame for a simple card game?

I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game?
adam
  • 6,090
  • 3
  • 26
  • 27
6
votes
5 answers

Java - How to create a deck of cards (with a focus on static arrays)? - AP Computer Science Project

this is my first question ever. Just to clarify, I did check to see if there were any questions that could have helped me before asking this. Apologies in advance if I do anything incorrectly, I'm new. Anyways, for my AP CS class I must make a deck…
user9125722
1
2 3
19 20