Re: [stella] Thinking like a computer (harder than it sounds)

Subject: Re: [stella] Thinking like a computer (harder than it sounds)
From: Erik Mooney <emooney@xxxxxxxxxxxxxxxx>
Date: Tue, 1 Jun 1999 10:13:54 -0400 (EDT)
> As we only need 6 bits of every byte, we can overlap the cards in
> memory, every four cards in three bytes:
> 
> AAAAAABB BBBBCCCC CCDDDDDD EEEEEEFF FFFFGGGG GGHHHHHH

Don't forget that someone's also gonna have to *draw* a screen with all
these cards.  I doubt you'd have time to extract card values out of that
packing during a screen kernel, and you can forget about using Andrew
Davie's packing method for that :)  I'd use one byte per card to make that
a good deal simpler.

> For the build piles, Erik pointed out that you can draw these out
> randomly from the deck at the point they are uncovered, instead of
> actually tracking them all along...  This is sound thinking.  Once

Actually, my original method for that was a bit flawed.  I was using extra
values to keep track of how many cards were in each face-down pile.
There's no need for that.  Just make it one linear array: the first spot
will be the card in the first pile, the next two spots the cards in the
next pile, the next three spots the cards in the third pile, and so on.
And use 0 to indicate 'no card'.  Keeping track of how many cards in each
pile is unnecessary.  Since you need to keep the undealt cards somewhere,
you may as well just deal them into that array at game start instead of
into the deck.

> Now, we still need to keep track of the up cards...  Another trick
> Erik mentioned was that we only need to keep track of the SUITS of
> the cards underneath the top.  So, we need 7 bytes for the top

Actually, you need but _one_ bit, not two, for each card after the first.
After the first card, you know what color each card below will be, so you
only need one bit to distinguish suit.  E.g., if the top card is the queen
of spades, you only need one bit to tell whether the next one is the jack
of hearts or the jack of diamonds.  Of course, you need some counter to
keep track of how many cards in the stack (your terminator won't work
anymore.)  Still, though, that's 6 bits for the top card plus 4 for the
counter plus 12 for the other cards; smaller than your 6 bits for the top
card plus 2 each for 12 other cards.  Saves another whole byte per stack.


--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread