Talk:Deal cards for FreeCell: Difference between revisions

added a new talk section.
(added a new talk section.)
Line 40:
 
: Lost visibility now restored [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 15:28, 21 November 2016 (UTC)
 
==support for games -1 and -2==
Most people aren't aware of an undocumented support for:
:::*   game   -1       and
:::*   game   -2
 
 
 
Here is a REXX version that supports those (minus) games:
<lang rexx>/*REXX program deals cards for a specific FreeCell solitaire card game (0 ──► 32767).*/
numeric digits 15 /*ensure enough digits for the random #*/
parse arg game cols . /*obtain optional arguments from the CL*/
if game=='' | game=="," then game=1 /*No game specified? Then use default.*/
if cols=='' | cols=="," then cols=8 /* " cols " " " " */
state=game /*seed random # generator with game num*/
suit= '♣♦♥♠' /*default: ASCII symbols for the suits.*/
if game==-2 then suit= '♠♥♦♣' /*a special suit order for game ≡ -2 */
if 8=='f8'x then suit=translate(suit,"cdhs",suit) /*EBCDIC? Use letters for suits.*/
rank= 'A23456789tJQK' /*t in the rank represents a ten (10).*/
if game==-1 then rank= 'AQ3t587694J2K' /*a special rank for a game of -1. */
if game==-2 then rank= 'A7K6Q5J4t3928' /*" " " " " " " -2. */
__=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.*/
#=-1; do r=1 for length(rank) /*build the deck first by the rank. */
do s=1 for length(suit); #=#+1 /* " " " secondly " " suit. */
@.#=substr(rank, r,1)substr(suit, s,1) /*build the $ array one card at at time*/
end /*s*/ /* [↑] first card is number 0 (zero).*/
end /*r*/ /* [↑] build deck per FreeCell rules. */
$=__ /*@: cards to be dealt, eight at a time*/
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.*/
if game<0 then $=$ minus()
else $=$ @.?; @.?= @.cards /*swap two cards: use random and last.*/
if words($)==cols then do; say $; $=__; /*deal FreeCell cards for the tableau. */
end
end /*cards*/ /*normally, 8 cards are dealt to a row.*/
/* [↓] residual cards may exist. */
if $\='' then say $ /*Any residual cards in the tableau ? */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
rand: state=(214013*state + 2531011) // 2**31; return state % 2**16 /*FreeCell rand#*/
minus: s=s+1; if s==5 then do; r=r+1; s=1; end; return substr(rank,r,1)substr(suit,s,1)</lang>
{{out|output|text=&nbsp; when using the input of: &nbsp; <tt> -1 </tt>}}
<pre>
───────────tableau for FreeCell game -1───────────
 
A♣ A♦ A♥ A♠ Q♣ Q♦ Q♥ Q♠
3♣ 3♦ 3♥ 3♠ t♣ t♦ t♥ t♠
5♣ 5♦ 5♥ 5♠ 8♣ 8♦ 8♥ 8♠
7♣ 7♦ 7♥ 7♠ 6♣ 6♦ 6♥ 6♠
9♣ 9♦ 9♥ 9♠ 4♣ 4♦ 4♥ 4♠
J♣ J♦ J♥ J♠ 2♣ 2♦ 2♥ 2♠
K♣ K♦ K♥ K♠
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; <tt> -2 </tt>}}
<pre>
───────────tableau for FreeCell game -2───────────
 
A♠ A♥ A♦ A♣ 7♠ 7♥ 7♦ 7♣
K♠ K♥ K♦ K♣ 6♠ 6♥ 6♦ 6♣
Q♠ Q♥ Q♦ Q♣ 5♠ 5♥ 5♦ 5♣
J♠ J♥ J♦ J♣ 4♠ 4♥ 4♦ 4♣
t♠ t♥ t♦ t♣ 3♠ 3♥ 3♦ 3♣
9♠ 9♥ 9♦ 9♣ 2♠ 2♥ 2♦ 2♣
8♠ 8♥ 8♦ 8♣
</pre>