[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] APL vs. Perl. A query from a lazy programmer.



Keith Calvert Ivey wrote:
> 
> But I still don't think the method of distributing cards is
> right. Like Rick Delaney, you're going through one suit at a
> time and distributing each card to a random player.  You've
> added a check to make sure you no player gets more than 13
> cards, so the difference from a real deal is more subtle, but
> it's still there.

Indeed, that approach is fundamentally flawed.

In my solution, posted ealier,  I shuffle the deck and then
do a 1-card distributive deal (like real life).  I thought
I'd simply divide the shuffled deck in four chunks, but it
turned out a deal was simpler.  
But here's a different idea (maybe abigail can analyze it):

	while (@deck) { # not shuffled
		push @{$hand{($h++)&3}, shift $deck[rand $#deck];
	}

That is, instead of shuffling the deck and then dealing
the deck in sequence, simply deal cards randomly selected
from the deck.

-- 
John Porter


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe