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

Subject: Re: [stella] Thinking like a computer (harder than it sounds)
From: slapdash@xxxxxxxxxxxx (Russ Perry Jr)
Date: Wed, 2 Jun 1999 22:48:34 -0600
>> >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.

>> True.  Of course, to avoid packing & unpacking time, we'll just use one
>> byte for the top card, and exactly two bytes for the up stack.  I assume
>> we'd start those two bytes with the counter itself?

>You could probably do that - 12 bits for the stack and 4 for the counter
>should compress neatly into two bytes.

Right, only I was also asking if it made sense that the counter itself by
first to make accesses down the list easier...

>> Well, actually, I had the (uncompressed) ace piles at 4 bytes, but if
>> we use one byte to store the order of suits (you'd have to juggle a
>> terminator state, starting with/alternating 00000000 and 11111111 states
>> as you added), then you'd only need two bytes (4 nibbles) for the top
>> card values, saving one more byte.

>What I'd do is just hardcode the ace piles into a fixed order.. that
>solves everything there.

Yep, I'd proposed that same thing in my original post actually...

I realized something else though...

I originally assigned room for the deck at 52 bytes (uncompressed) and
the build pile up cards 7 bytes (ditto).  Hell, there's no need to do
both!  Those 7 cards are part of the deck, and the last dealt, and we
DON'T have to make extra room for them!

So, our memory now will be:

24 bytes = cards in our draw pile
21 bytes = down cards in the build piles
 7 bytes = top up card in the build piles
(that's 52 bytes for 52 cards so far)
14 bytes = up cards below the top card in the build piles
 4 bytes = ace piles (unordered; in order only 2 bytes)
--------
70 bytes

Not a big bad number considering that we've done very little compressing
or encoding...  Plenty of room (58 bytes) left for other program variables,
don't you think?

So Peter, is it done yet?  :-)

//*================================================================++
||  Russ Perry Jr   2175 S Tonne Dr #105   Arlington Hts IL 60005  ||
||  847-952-9729    slapdash@xxxxxxxxxxxx    VIDEOGAME COLLECTOR!  ||
++================================================================*//



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

Current Thread