| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
C++ War Game HELP NEEDED
|
Original Message
|
Name: nataku954
Date: March 23, 2005 at 21:20:00 Pacific
Subject: C++ War Game HELP NEEDEDOS: XP ProCPU/Ram: Pentium M 1.5/512 |
Comment: I accidently posted this in the XP area...I am attempting to make a C++ program of a war card game for my programming class. Right now all that i have to do is randomly shuffle and split the deck. I got that to work...but i need a way to limit the number of cards that can be drawn of a certain type because i am drawing like 6 Kings and 8 threes...which would be impossible with just a regular deck. Does anyone know what i can do to limit this to only draw 4 cards of the same type???
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: wizard-fred
Date: March 24, 2005 at 01:00:50 Pacific
|
Reply: (edit)Define an array of 52 cards, then when drawing check for duplicate cards. This way you can get only one card each. If you get 6 Kings and 8 threes, then check your shuffle and deal routine, because it isn't too random.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
|
Reply: (edit)as wizard-fred said define an array of 52 cards with the values the array. then what you want to do is randomly select a point in the array then draw that card out of the array.by taking the last eliment and puting it in that space and now saying the array is one shorter using a int count that says how many cards are left in the deck. do the same for the next card but use the count to say how long the array is so that you can only take cards from the pack that havent been taken and repeat the same process of taking the element out and reducing count by one. do that for each card off the pack.
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Programming Forum Home