Talk:Deal cards for FreeCell: Difference between revisions
Content added Content deleted
m (→support for games -1 and -2: made some cosmetic changes.) |
(→support for negative games: added support for games -3 and -4.) |
||
Line 41: | Line 41: | ||
: Lost visibility now restored [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 15:28, 21 November 2016 (UTC) |
: Lost visibility now restored [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 15:28, 21 November 2016 (UTC) |
||
==support for games |
==support for negative games== |
||
Most people aren't aware of an undocumented support for: |
Most people aren't aware of an undocumented support for: |
||
:::* game -1 and |
:::* game -1 and |
||
:::* game -2 |
:::* 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: | Line 69: | ||
state=game /*seed random # generator with game num*/ |
state=game /*seed random # generator with game num*/ |
||
suit= '♣♦♥♠' /*default: ASCII symbols for the suits.*/ |
suit= '♣♦♥♠' /*default: ASCII symbols for the suits.*/ |
||
if game |
if game< -1 then suit= '♠♥♦♣' /*special suit order for games -2 -3 -4*/ |
||
⚫ | |||
rank= 'A23456789tJQK' /*t in the rank represents a ten (10).*/ |
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==-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. */ |
||
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*/ |
|||
⚫ | |||
suit =translate(suit, "cdhs", suit) |
|||
minus4=translate(minus4, "cdhs", suit) |
|||
end |
|||
pad=left('', 13) /*used for indentation for the tableau.*/ |
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 #*/ |
||
Line 71: | Line 93: | ||
$=pad /*@: cards to be dealt, eight at a time*/ |
$=pad /*@: cards to be dealt, eight at a time*/ |
||
r=1 |
r=1 |
||
s=0; do cards=51 by -1 for 52 |
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.*/ |
?=rand() // (cards + 1) /*get next rand#; card # is remainder.*/ |
||
if game<0 then $=$ minus() |
|||
if game<0 & game>-4 then $=$ nega() /*handle special for games -1, -2, -3 */ |
|||
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. */ |
if words($)==cols then do; say $; $=pad /*deal FreeCell cards for the tableau. */ |
||
end |
end |
||
Line 82: | Line 108: | ||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
rand: |
rand: state=(214013*state + 2531011) // 2**31; return state % 2**16 /*FreeCell rand#*/ |
||
nega: if s==5 then do; r=r+1; s=1; end; return substr(rank,r,1)substr(suit,s,1) |
|||
neg4: return substr(minus4, s+s-1, 2)</lang> |
|||
{{out|output|text= when using the input of: <tt> -1 </tt>}} |
{{out|output|text= when using the input of: <tt> -1 </tt>}} |
||
<pre> |
<pre> |
||
Line 107: | Line 134: | ||
9♠ 9♥ 9♦ 9♣ 2♠ 2♥ 2♦ 2♣ |
9♠ 9♥ 9♦ 9♣ 2♠ 2♥ 2♦ 2♣ |
||
8♠ 8♥ 8♦ 8♣ |
8♠ 8♥ 8♦ 8♣ |
||
</pre> |
|||
{{out|output|text= when using the input of: <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= when using the input of: <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> |
</pre> |