Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 03 Aug 2014 12:52:52 -0500 Date: Sun, 03 Aug 2014 18:52:51 +0100 From: lipska the kat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Help with Deck of cards assignment and getting it to deal... References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 42 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-rAoSWCkiEh9qAEwJ0Ix7oMFUTGEFan6RuYh7QeNaQtzXyh405N3R0JBD41g+HmiCcDDhxMWqTIZCAEc!I0Au7LQSjni3sQ8xsaa7k7xjysz79JgtJTRUSdW9LnC8zYJU4Ocg/sHN4gs2+5ZB4qVZVB2O2Xk= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2892 Xref: csiph.com comp.lang.java.programmer:29525 On 03/08/14 15:23, Eric Sosman wrote: > On 8/1/2014 9:16 PM, Scott Dunning wrote: > Others have observed that this shuffling procedure is biased, > and suggested alternatives. I'd just like to point out that it > may not be necessary to shuffle at all! > > Here's the idea: The fundamental operation is "deal one card" > (you can do this N times in succession to deal N cards). Judging > by your `currentCard' variable, you plan to shuffle the deck and > then march through it in sequence, dealing the first, second, ... > card in succession. That will work fine (if you shuffle well). > > But what if you just left the deck in any old order at all, > even "factory-fresh" with all the suits and ranks in order, *but* > instead of dealing sequentially you dealt a randomly-chosen card? This is a poor abstraction I'm afraid. One of the things we try to teach when we teach an OO language is the concept of the real world abstraction. In the real world, if you dealt a 'randomly chosen card' your opponent[s] might be forgiven for `popping a cap in yo' ass` :-) Not only is a shuffle method required by the specification but it is a realistic real world abstraction, also it removes any additional complexity involved in keeping track of which cards have been dealt. I believe that if you do this in 'Vegas (card counting that is) you will be politely shown the door by a number of large European gentlemen with a penchant for olive oil. -- lipska the kat - treacherous feline. Proudly nominated for IPOTY 2014 - LIGAF GNU/Linux user #560883 - linuxcounter.net