|
-
Mar 20th, 2001, 10:10 PM
#1
Thread Starter
Lively Member
I have to make a solitare type game....but the problem is shiffling...I have these requirements.
I am Given 52 cards i order of their suits. (i.e Ace of Spades, then 2 Spades, 3, 4, 5, 6, and so on untill Hearts, Diamonds and Club.)
First I have to take N amount of cards from the Center in this case 12. So i have to remove 12 cards from the middle that is cards 20 to 31 and move these to the top of the deck then i have to take 4 cards from the center again and place them on the bottom of the deck. This has to to be repeated 4 times and i have to find out what card is on top after 4 repetitions. Help me understand this... I m trying to do it in a list box but i just can't seem o wrap my head around it.
Thanks a lot for the help in the past
-
Mar 20th, 2001, 11:03 PM
#2
PowerPoster
Just a try
Couldn't you load all 52 into listbox, then remove cards, place half at them top of the list (additem and listindex) and then the other half at the bottom of the list?
I have not tried it, just a theory...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2001, 11:07 PM
#3
Thread Starter
Lively Member
yes but how can that be done????
-
Mar 20th, 2001, 11:13 PM
#4
PowerPoster
Theory time agin...
Use two lisboxes
Load 1st with 52 cards.
Create for loop which will remove 12 cards from listbox
1 by 1 and add them to listbox2 (as these card are being added to 2, delee them from one). Then take the first six from listbox2 and add them to the top of listbox1 - (listbox1.additem "card", 0) 0, I belive is the first position. Then the remaining 6 in listbox2, add to the bottom of listbox1 (listbox1.additem "card" , (index - here detremine the count of the item in list1 +1). This would add these cards to the bottom of list1. Then delete the twelve entries in list2.
I wish you luck. I tired from just typing the theory...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2001, 11:18 PM
#5
Thread Starter
Lively Member
ok but i want to remove 12 from the middle, how do i tell vb to remove from the middle of the list box. Removing it from the top is easy but how from the middle. By this i mean what code would lets say remove items 20 to 31 from the listbox i must figure this out.please help!!!
-
Mar 20th, 2001, 11:24 PM
#6
PowerPoster
Index
Can't you remove form the index of the item in the listbox?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Mar 20th, 2001, 11:42 PM
#7
Thread Starter
Lively Member
ya if you select it your self it would delete but how can that be done from code?
-
Mar 21st, 2001, 01:27 AM
#8
PowerPoster
I mmay not be getting it right but should't this solve your problem:
Code:
'put the code in a while loop for the amountof items you want to remove
list1.RemoveItem <Index>
-
Mar 21st, 2001, 10:22 AM
#9
Addicted Member
Cards and VB
I found after making a Card program for Deadlands that the easiest way to handle cards is to create a collection of all the cards (including the jokers).
To draw a card, then just use the Randomize/RND() function (as described in the help files) and use the number as the index to pull a card. To simulate it being pulled from the deck, you can use the .remove method for the collection and effectively it will be removed.
This is a lot simpler than worrying about shuffling, because to reshuffle the deck, just destroy the original collection and recreate it again, then use the same random method to draw a card.
Easy stuff. I have the code at home if you want to see it.
Eiredrake
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|