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