<div dir="ltr">On Fri, Aug 22, 2008 at 1:30 AM,  <span dir="ltr">&lt;<a href="mailto:Tcykgreis@aol.com">Tcykgreis@aol.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;"><font size="2" color="#000000" face="Arial">
<div>I have had a curiosity about Smalltalk for many years so I recently 
downloaded and installed Squeak. That&#39;s when the trouble began. I have written 
applications that deal bridge hands and either display the hands on screen or 
save them in a couple of different formats. I originally wrote the &#39;words&#39; in 
Forth. I later tried Ruby and rewrote most of the programs in Ruby. I did it as 
a learning experience. I sat out to do the same thing in Squeak, again as a 
learning experience, but have made virtually no progress. I create the class 
&#39;Bridge&#39; with the subclass of dealer. I try to initialize by filling a byteArray 
with 52 numbers, 0 through 51. </div></font></div></blockquote><div><br>Woah...what? This doesn&#39;t really make any sense.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;"><font size="2" color="#000000" face="Arial"><div>I tended to create additional methods to shuffle 
and deal the cards to four more byte arrays named north, east, south, and west. 
Eventually I will need another method to &quot;stack the deck.&quot; I will also need a 
counter to keep track of the deal number.</div>
<div>&nbsp;</div>
<div>I can&#39;t get started, and I mean zero progress, because I can&#39;t create and 
load deck. It seems like the documentation is never quit up to date. I read 
about curly braces and tried deck := {0. 1. 2. ... }. When I try to accept it, 
first deck is questioned and then after deck I get something about not expecting 
anything else.</div></font></div></blockquote><div><br>This is because deck is undeclared, and then because you have a syntax error.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;"><font size="2" color="#000000" face="Arial"><div></div>
<div>I know there is a word &#39;asByteArray:&#39; and I assume a number would specify 
the size of the array but nowhere can I find anything about the order in which 
the information should be provided. I tried deck asByteArray: 52 but I don&#39;t 
know if it worked. If it did work, how do I load the bytes into it? How do I 
look at a byte in a particular location in the array? Can I remove a byte from 
position x and/or insert a byte at position y and everything moves to 
accommodate the change.</div></font></div></blockquote><div><br>First of all, are you familiar with the syntax? <br><br>Squeak by example will help guide you through looking at classes, and seeing what methods they have etc. <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;"><font size="2" color="#000000" face="Arial"><div>
</div>
<div>&nbsp;</div>
<div>In Forth and Ruby, I was able to store the hands as a 2D bit array, 4 suits 
and 13 bits. If the card was present the bit was set. When I dealt the cards, 
the appropriate bits were set.. This worked really well. The suits came out 
already sorted. The strength of a suit turned out to be related to the value 
stored for the suit. The number of cards in the suit could be found by counting 
set bits. I have yet to find bit-manipulating words in Squeak/Smalltalk.</div>
<div>&nbsp;</div>
<div>As an aside, the least number of bits that must be used to store a complete 
deal is 104 or 13 bytes. The bits are arranged in 52 2-bit groups. The position 
in the array represents the value of the card and the bits determine which hands 
gets the card represented by that position. When you shuffle the 2-bit groups 
must be kept in tact. I could easily do this in Forth but could not do it in 
Ruby. If you are going to save a few million hands, it is nice to be able to do 
so in this most compact form.</div>
<div>&nbsp;</div>
<div>If I could just figure out where to find the answers to these beginner 
question, I would really appreciate it. It would also be nice if I could see 
some examples of these methods.</div>
<div>&nbsp;</div>
<div>Charlie</div>
<div>&nbsp;</div></font></div></blockquote><div><br>I would recommend that you create a card class, with a member variable that represents the suit (probably as a symbol) and a second member variable that represents the card in the suit. Create a class method that returns new instances (eventually have it throw an exception if something out of the range of what is acceptable is created) and have a second class method that creates a collection of cards that contains all the cards, in order. You can use the methods on the appropriate collection to shuffle it.<br>
<br>Once you&#39;ve built something working on that, you can try to optimise storage, either on disk or in memory. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="font-size: 10pt; color: rgb(0, 0, 0); font-family: Arial;"><font size="2" color="#000000" face="Arial"><div></div>
<div>&nbsp;</div></font><br><br><br><div><font style="color: black; font-family: ARIAL,SAN-SERIF; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><hr style="margin-top: 10px;">
It&#39;s only a deal if it&#39;s where <i>you</i> want to go. Find your travel deal <a title="http://information.travel.aol.com/deals?ncid=aoltrv00050000000047" href="http://information.travel.aol.com/deals?ncid=aoltrv00050000000047" target="_blank"><b>here</b></a>.</font></div>
</div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>