Cribbage Game

This is a discussion on Cribbage Game within the Game Programming forums, part of the General Programming Boards category; Hey everyone, I was bored last week and put together a console-base cribbage card game. I'm currently working on updating ...

  1. #1
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728

    Cribbage Game

    Hey everyone, I was bored last week and put together a console-base cribbage card game. I'm currently working on updating it to a windows format. The AI is pretty strong, although be warned, it is NOT forgiving if you do not know how to play cribbage. Let me know what you think!

    Here is the executable:
    Attached Files Attached Files

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    And here are the source files for those who want to compile it instead:
    Attached Files Attached Files

  3. #3
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Cool!

    Edit- I'm not being sarcastic seriously, cool.

  4. #4
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    LOL, I'm guessing from the lack of downloads so far that few people know how to play cribbage. Thats too bad, its a fun card game!

  5. #5
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Perhaps if you wanted to "draw in the crowd" you shoulda went and programmed a more 'traditional' card game. Something like, strip poker.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #6
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    LOL, thought about it, but then realized that I'm not too confident in my ASCII art to draw anything anyone would want to look at.

    I am working on a straight poker engine though, having problems with making the dang AI too predictable.

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I don't really know how to play cribbage, but the game looked nicely programmed.
    Away.

  8. #8
    Registered User
    Join Date
    Feb 2003
    Posts
    41

    Re: Cribbage Game

    Originally posted by PJYelton
    Hey everyone, I was bored last week and put together a console-base cribbage card game. I'm currently working on updating it to a windows format. The AI is pretty strong, although be warned, it is NOT forgiving if you do not know how to play cribbage. Let me know what you think!

    Good but, you should all the user to either count there own cards OR get it done auto, since theres so many versions of crib out there some peoples rules and counting are different than what you have set

  9. #9
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Errr... I'm not sure what you mean by counting the cards, do you mean when you are adding up points? Right now it is set up so the user DOES count up their own points.

    And the rules I have set up are the "official" rules of the game, but I agree that many people have different versions. I was going to have instructions in the game but never got around to it

  10. #10
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    Yes i know the user counts his own cards, im saying they should have a choice to count there cards or have them counted by the comp, and offical rules are different depending on were you got them since ppl in diff countries even different familys play different

  11. #11
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    I gotcha, that makes sense. If I get around to it I'll add that feature in to allow the comp to add up human cards. BTW, do you play with different rules? I'm curious what rules you use if they aren't the same.

  12. #12
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    well

    anything that adds up to 15 is 2 points
    run of 3 is 3
    run of 4 is 6 (not 4)

    3 of a kind is 6
    2 of a kind is 2

    kings, queens, jacks are 10

    if you cut the deck and get a "one eyed jack" you get 2 points

    if you have the jack of the same suit of the card that was cut you get 2 points

    theres more just i cant remeber

    BTW: what card is the "T" that shows ups?

  13. #13
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Probably the triskadekaphobia card...
    If you ever need a hug, just ask.

  14. #14
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Wow, those are some crazy rules you got there. The T stands for 10. I don't print the "10" because its a real pain and not worth the effort to constantly have to check to see if the card is equal to ten to account for its two spaces when all other cards only need 1.

    Here are the rules my game uses taken from Hoyle:
    Introduction

    Six Card Cribbage is a game for two players.

    Object

    To be the first to score 121 points or over accumulated over several deals. Points are scored mainly for combinations of cards either occurring during the play or occurring in a player's hand or in the cards discarded before the play, which form the crib or box.

    Deal

    The first deal is determined by cutting the cards. The player cutting the lower card deals and has the first box or crib. The deal then alternates from hand to hand until the game is over.

    The dealer shuffles, the non-dealer cuts the cards and dealer deals 6 cards face down to each player one at a time. The undealt part of the pack is placed face down on the table. At the end of each hand, the played cards are gathered together and the whole pack is shuffled before the next deal.

    Discard

    Each player chooses two cards to discard face down to form the crib. These four cards are set aside until the end of the hand. The crib will count for the dealer. The non-dealer will try to throw cards that are unlikely to make valuable combinations, but must balance this against keeping a good hand for himself. The dealer, on the other hand, may sometimes find it pays to place good cards in the box - especially if they cannot be used to best advantage in hand.

    Start Card

    The non-dealer cuts the stack of undealt cards, lifting the upper part without showing its bottom card. The dealer takes out the top card of the lower part, turns it face up and places it face up on top of the pack. This turned up card is called the start card - it will count for combinations as part of both players' hands as well as of the dealer's box. If the start card is a jack, the dealer immediately gets points - this is called Two for his heels.

    Play of the cards

    Starting with the non-dealer, the players take turns to play single cards. You play your own cards to form a face-up pile in front of yourself, keeping them separate from the other players' cards. In this stage of the game the total pip value of the cards played by both players must not exceed 31.

    The pip values of the cards are:

    Ace = 1

    2 to 10 = face value

    jack, queen, king = 10
    As each card is played the running total is kept. If a card is played which brings the total exactly to 31, the player pegs 2 claiming Thirty one for two as he does so.

    A player who cannot play without exceeding 31 does not play a card but says Go, leaving his opponent to continue if possible, pegging for any further combinations made (see below). Bringing the total to exactly 31 pegs 2, but if neither player can lay a card without going over 31, then the last player to lay a card pegs one for the go or one for last.

    The cards that have been played are turned over and a fresh round of play starts with the unplayed cards in exactly the same way. This second round of play again continues until neither can play without going over 31. The last player again scores one for last or thirty one for two, and if either player has any cards left there is a further round. Play continues for as many rounds as necessary until both players' cards are exhausted. Towards the end, it may happen that one player has run out of cards but the other still has several cards. In that case the player who still has cards simply carries on playing and scoring for any combinations formed until all his cards have been played.

    Tactical note: It is often worth keeping low cards in hand for this phase of the game, especially when there is a strong possibility of being able to peg out before one's opponent.

    Scoring during the play

    A player who makes any of the following scores during the play pegs them immediately.

    15 : If you play a card which brings the total to 15 you peg 2 claiming Fifteen two.

    31 : As mentioned above, if you play a card which brings the total to 31 you peg 2.

    Pair : If you play a card of the same rank as the previous card (e.g. a king after a king) you peg 2 for a pair. Note that (for example) a 10 and a queen do NOT make a pair even though they are both worth 10 points.

    Pair Royal : If immediately after a pair a third card of the same rank is played, the player of the third card scores 6 for pair royal.

    Double Pair Royal : Four cards of the same rank, played in immediate succession. The player of the fourth card scores 12.

    Run : A run or sequence is a set of 3 or more cards of consecutive ranks (irrespective of suit) - such as 9-10-jack or 2-3-4-5. The score is equal to the number of cards in the run. The cards do not have to be played in order, but no other cards must intervene.

    Last Card : If neither player manages to make the total exactly 31, whoever played the last card pegs 1.

    The Show

    Players now retrieve the cards that they put down during the play and score for combinations of cards held in hand. First the non-dealer's hand is exposed, and scored. The start card also counts as part of the hand when scoring combinations. All valid scores from the following list are counted.

    15 : Any combination of cards adding up to 15 pips scores 2 points.

    Pair : A pair of cards of the same rank score 2 points. Three cards of the same rank contain 3 different pairs and thus score a total of 6 points for pair royal. Four of a kind contain 6 pairs and so score 12 points.

    Run : Three cards of consecutive rank (irrespective of suit), such as ace-2-3, score 3 points for a run. A hand such as 6-7-7-8 contains two runs of 3 (as well as two fifteens and a pair) and so would score 12 altogether. A run of four cards, such as 9-10-J-Q scores 4 points, and a run of five cards scores 5.

    Flush : If all four cards of the hand are the same suit, 4 points are scored for flush. If the start card is the same suit as well, the flush is worth 5 points. There is no score for having 3 hand cards and the start all the same suit. Note also that there is no score for flush during the play - it only counts in the show.

    One For His Nob : If the hand contains the jack of the same suit as the start card, you peg One for his nob.

    After non-dealer's hand has been shown and the score pegged, dealer's hand is shown, scored and pegged in the same way. Finally the dealer exposes the four cards of the crib and scores them with the start card.

    Winning the game

    As soon as someone reaches or passes 121, that player wins the game. This can happen at any stage - during the play or the show, or even by dealer scoring two for his heels.

  15. #15
    Registered User
    Join Date
    Feb 2003
    Posts
    41
    ya i use most of those rules but change a few, my friends play totally wacked rules

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-07-2010, 11:08 PM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. C++ Game of Life Program
    By rayrayj52 in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 03:58 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21