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!

324 questions
6
votes
3 answers

Looking for arithmetic operations that result in 24

I'm writing a program that evaluates the integer values of 4 playing cards (numbers 1-13), and displays a solution that equals 24. I have a large if statement that I've written for this and have realized that there are just too many solutions to add…
John Doe
  • 107
  • 1
  • 8
6
votes
2 answers

F# modeling playing cards

I am trying to represent standard playing cards in F#. My goal is to implement a clone of Microsoft Solitaire (the one that comes with Windows) , a game in which Cards' Suit, Face, and Color are important. This exercise is mostly intended as a way…
theguy
  • 861
  • 9
  • 19
6
votes
4 answers

Repeating vectors in Clojure

I am a Clojure newbie. I am trying to get two copies of a vector of card suits. The non-DRY way that I can come up with is (def suits [:clubs :diamonds :hearts :spades]) (def two-times (concat suits suits)) There must be a more functional way (even…
Ralph
  • 31,584
  • 38
  • 145
  • 282
5
votes
1 answer

OOP Design for Card Game Classes

What would be the best approach when designing the following classes applying design patterns? Deck - addCard, deal, shuffle, getTopCard, removeTopCard, removeAllCards Hand - addCard, removeCard, getCard,removeAllCards DiscardPile - addCard,…
Zack
  • 243
  • 2
  • 4
  • 8
5
votes
3 answers

Best card choice in card game in C#

The problem consists in choosing the best option at every moment of the game following these rules: You can only pick the leftmost or the rightmost card. Your opponent will ALWAYS pick first, and will ALWAYS choose the highest card from either the…
5
votes
1 answer

AI Algorithm Design: Card game

Currently I'm working on implementing a spanish card game called Briscas, or Briscola,http://en.wikipedia.org/wiki/Briscola In a nutshell, it's a card game where two teams of 2 players play against each other (they can't see each others hand, not…
meteorfox
  • 575
  • 1
  • 5
  • 13
5
votes
1 answer

Sort a deck of cards

Given a deck of N cards. You have to sort them using following permissible operations: You can see top 2 cards. You can swap them. You can insert top at the bottom. Any ideas?
abhishekgarg
  • 164
  • 1
  • 4
  • 11
5
votes
2 answers

Ready-made Javascript library for modelling card games?

MVC 'architecture'. I would like a convenient way of specifying the rules of a card game including aspects such as hands or tricks, scoring, which cards from the deck or pack are used, and so on. Does anyone know of anything like this, preferably in…
5
votes
3 answers

Genetic algorithm for a card game (Dominion)

I have a working F# program that runs Dominion, a card game. I would like to use a genetic algorithm to determine optimal strategies for playing. However, I don't know much about AI or genetic algorithms. Can you point me towards some good…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
4
votes
2 answers

HTML5 card game

I created a card game in silverlight a year or so ago in order to learn a bit about Silverlight. I am now wanting to make a HTML5 version of the game in an effort to learn a little bit more about that. I am thinking I'd like to take advantage of…
ChrisCa
  • 10,876
  • 22
  • 81
  • 118
4
votes
0 answers

How to solve combinations in card game for n people in r rounds (just one encounter)

There is a famous card game in Germany called "Doppelkopf". Usually, you play "Doppelkopf" with 4 players, but you can also play it with a table of 5 players, where one player is just watching. (Where everyone "has the cards" once in a round,…
Wisa
  • 109
  • 6
4
votes
7 answers

How to Test if a Deck of Cards Has Been Shuffled Enough in Java

I have to test and see if this method has shuffled a deck of cards. Here if the code for the actual shuffling part. public void randomShuffle () { for (int i = 0; i < DECK_SIZE; i++) { int place =…
frodosamoa
  • 973
  • 2
  • 11
  • 13
4
votes
3 answers

Extract a portion of an image in .NET

I have a PNG of a deck of cards as 1 image (it has all 52 cards combined into 1 image file). How do I extract an individual card out as I need it (or extract them all into separate image files at start up). I understand the logic of know which row…
user1906484
  • 51
  • 1
  • 2
3
votes
2 answers

Architecting a collectable card game

I'm trying to learn how to program a (virtual) Trading Card Game game (similar to Magic the Gathering) in Javascript. I've read a little about MVC architecture and controllers, but it's all over my head (I don't have any formal CS education) and I'm…
Adam Hunter Peck
  • 267
  • 1
  • 3
  • 14
3
votes
4 answers

Reverse Fisher-Yates Shuffle in C#

I'm trying to create a console program to simulate having a deck of cards, the user should be able to; Pick a number of cards at random Shuffle the deck Return the deck to its original state I'm struggling to figure out a way to return the deck to…
Mivox
  • 31
  • 1
1
2
3
21 22