Results 1 to 9 of 9

Thread: ***---Shuffling---***

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation

    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

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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....

  3. #3

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    yes but how can that be done????

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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....

  5. #5

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    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!!!

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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....

  7. #7

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    ya if you select it your self it would delete but how can that be done from code?

  8. #8
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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>

  9. #9
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163

    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
  •  



Click Here to Expand Forum to Full Width