Talk:Deal cards for FreeCell: Difference between revisions

→‎support for negative games: added support for games -3 and -4.
m (→‎support for games -1 and -2: made some cosmetic changes.)
(→‎support for negative games: added support for games -3 and -4.)
Line 41:
: Lost visibility now restored [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 15:28, 21 November 2016 (UTC)
 
==support for negative games -1 and -2==
Most people aren't aware of an undocumented support for:
:::*   game   -1       and
:::*   game   -2
 
 
Windows 7 (and up) have undocumented support for two additional games:
:::*   game   -3       and
:::*   game   -4
 
 
You can't possibly win games    -1   and   -2.
 
You can't possibly lose games   -3   and   -4.
 
 
It is entertaining to watch the   -3   and   -4   games play out.
 
 
Line 56 ⟶ 69:
state=game /*seed random # generator with game num*/
suit= '♣♦♥♠' /*default: ASCII symbols for the suits.*/
if game==< -21 then suit= '♠♥♦♣' /*a special suit order for game ≡ games -2 -3 -4*/
 
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. */
if game==-3 then rank= 'K6Q5J4t3928A7' /*" " " " " " " -3. */
 
minus4= space('K♣Q♣t♦8♥6♣5♦3♣2♦ K♥J♣t♣8♦6♥5♣3♥2♣ K♦J♦9♣8♣6♦4♣3♦A♣ K♣J♦9♥7♣6♣4♥3♣A♥' ,
'Q♣J♣9♦7♥5♣4♦2♣A♦ Q♥t♣9♣7♦5♦4♣2♥A♣ Q♦t♥8♣7♣', 0) /*tableau for game= -4*/
 
if 8=='f8'x then suit=translate(suit,"cdhs",suit)do /*EBCDIC? Then Useuse letters for suits. */
suit =translate(suit, "cdhs", suit)
minus4=translate(minus4, "cdhs", suit)
end
pad=left('', 13) /*used for indentation for the tableau.*/
say center('tableau for FreeCell game' game, 50, "─") /*show title for FreeCell game #*/
Line 71 ⟶ 93:
$=pad /*@: cards to be dealt, eight at a time*/
r=1
s=0; do cards=51 by -1 for 52; s=s + 1 /* [↓] deal the cards for the tableau.*/
?=rand() // (cards + 1) /*get next rand#; card # is remainder.*/
 
if game<0 then $=$ minus()
if game<0 & game>-4 elsethen $=$ @.?;nega() @.?= @.cards /*swaphandle special twofor cards:games use-1, random-2, and-3 last.*/
if game=-4 then $=$ neg4() /* " " " game -4 */
 
if game>=0 then $=$ @.?; @.?= @.cards /*swap two cards: use random and last.*/
 
if words($)==cols then do; say $; $=pad /*deal FreeCell cards for the tableau. */
end
Line 82 ⟶ 108:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
rand: state=(214013*state + 2531011) // 2**31; return state % 2**16 /*FreeCell rand#*/
minusnega: s=s+1; if s==5 then do; r=r+1; s=1; end; return substr(rank,r,1)substr(suit,s,1)</lang>
neg4: return substr(minus4, s+s-1, 2)</lang>
{{out|output|text=&nbsp; when using the input of: &nbsp; <tt> -1 </tt>}}
<pre>
Line 107 ⟶ 134:
9♠ 9♥ 9♦ 9♣ 2♠ 2♥ 2♦ 2♣
8♠ 8♥ 8♦ 8♣
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; <tt> -3 </tt>}}
<pre>
───────────tableau for FreeCell game -3───────────
 
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♣ A♠ A♥ A♦ A♣
7♠ 7♥ 7♦ 7♣
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; <tt> -4 </tt>}}
<pre>
───────────tableau for FreeCell game -4───────────
 
K♣ Q♣ t♦ 8♥ 6♣ 5♦ 3♣ 2♦
K♥ J♣ t♣ 8♦ 6♥ 5♣ 3♥ 2♣
K♦ J♦ 9♣ 8♣ 6♦ 4♣ 3♦ A♣
K♣ J♦ 9♥ 7♣ 6♣ 4♥ 3♣ A♥
Q♣ J♣ 9♦ 7♥ 5♣ 4♦ 2♣ A♦
Q♥ t♣ 9♣ 7♦ 5♦ 4♣ 2♥ A♣
Q♦ t♥ 8♣ 7♣
</pre>