Talk:Deal cards for FreeCell: Difference between revisions

m
→‎support for games -1 and -2: made some cosmetic changes.
(added a new talk section.)
m (→‎support for games -1 and -2: made some cosmetic changes.)
Line 61:
if game==-1 then rank= 'AQ3t587694J2K' /*a special rank for a game of -1. */
if game==-2 then rank= 'A7K6Q5J4t3928' /*" " " " " " " -2. */
__pad=left('', 13) /*used for indentation for the tableau.*/
say center('tableau for FreeCell game' game, 50, "─") /*show title for FreeCell game #*/
say /* [↓] @ is an array of all 52 cards.*/
Line 69:
end /*s*/ /* [↑] first card is number 0 (zero).*/
end /*r*/ /* [↑] build deck per FreeCell rules. */
$=__ pad /*@: cards to be dealt, eight at a time*/
r=1; s=0
s=0; do cards=51 by -1 for 52 /* [↓] deal the cards for the tableau.*/
?=rand() // (cards + 1) /*get next rand#; card # is remainder.*/
if game<0 then $=$ minus()
else $=$ @.?; @.?= @.cards /*swap two cards: use random and last.*/
if words($)==cols then do; say $; $=__;pad /*deal FreeCell cards for the tableau. */
end
end /*cards*/ /*normally, 8 cards are dealt to a row.*/