Re: A83: Black Jack


[Prev][Next][Index][Thread]

Re: A83: Black Jack




Jkhum98@aol.com wrote:

> In a message dated 10/10/99 10:42:34 AM Central Daylight Time,
> NathanG@firstva.com writes:
>
> > I'm making a Casino (For anyone who hasn't heard me say it a dozen
> >  times), and for the black jack portion, I need something to generate a
> >  random card (w/ suit since it will be graphical) Without repeats. I also
> >  can't make it destructive so that it eventually runs out of cards, all I
> >  need it to do is keep you from getting 2 aces of spades or anything like
> >  that. Any ideas?
>
> You could have an array of 54 numbers (all the cards) and create a routine to
> shuffle all those numbers throughout the array, which would involve program
> write back so that it could be even more random. To do the shuffling, you
> could use a random number routine and make it pick two integers between 1 and
> 54 (inclusive) and then swap the bytes at those two places, and do that
> sequence like 30 times or so, on each round. Then you could "draw" the cards
> from the front of that array, and just move a pointer up through the array to
> not reuse the cards....
>
> Btw, I have an idea on how you can do that byte storage to keep track of the
> cards... In a byte, each Nibble (4 bits) is capable of holding the numbers
> 0-15, and that is perfect for the amount of cards there are in a suit. So the
> number 1 corrosponds to an Ace, a 2 is the 2 card, a 15 is the king card,
> etc. And then that upper Nibble of a byte has the bits Set corrosponding to
> each suit. For example, Bit 7 is Set for the Spades, and Bits 6, 5, and 4 are
> reset. Bit 6 can be for Hearts, Bit 5 can be for Clubs, and Bit 4 can be for
> the Diamonds... Then when you grab these bytes out of the array, you do bit
> checking like so "BIT 7, a \ jp nz, Its_A_Spade" and then draw it
> accordingly... And then you mask off the top 4 bits to find the number on the
> card which is left in the lower nibble, and then draw that to the screen
> accordingly...
>
> I had this idea once when I got the urge to make a solitare game, but never
> carried that project out. I thought this idea was a damn good one though, but
> if anyone can think of a more efficient way for speed, randomness, byte
> storage, etc., I would surely like to hear it, thanks, and I hope my ideas
> could have helped a little bit, cya...
>
> Jason_K
> tcpa.calc.org

Great Idea! To keep from running out of cards, I could instead copy card one 1 to
card 52/54 spot (probably 52, I wont use jokers), or I could reshuffle if I got
to 52/54. This way I don't need to recreate the deck or anything, it can just
start off with the last deck, just like a real deck of cards.

I am pretty new to ASM, but I am learning VERY fast by jumping head-first into a
program like my casino (w/ a bar, restaraunt, slot machine, black jack, and 3
card monte as well as being able to start from where you left off). But I still
don't know how to do a lot of things. How would I go about setting this up?
Should I store the deck in an actual list/matrix? If so how do I switch using
ASM? If not how do I switch using ASM? Also, program writeback, I NEED this in my
program, but I can't seem to figure it out. I don't like using shells even though
they often have automatic program writeback as a standard feature. Also if anyone
out there really wants to se this dream become a reality, I am definitely looking
for hints to decrease file size. I do plan on squishing Casino, but it's still
going to be huge. I am avoiding the use of background images where I can (ie only
for the slot machine that really does need it).


--
"What, behind the rabbit?"-King Arthur
The Heat Index   Nathang@firstva.com
      http://users.firstva.com/Nathang
 (\\_
o(_;




References: