Difference between revisions of "Deal cards for FreeCell"
(→Program) |
(→Case 1. Deal #1) |
||
Line 80: | Line 80: | ||
=== Case 1. Deal #1 === | === Case 1. Deal #1 === | ||
+ | |||
+ | In order to show the result in bigger characters, we use the <code>SetFont</code> expression. The [[Null]] expressions are the font name, the indicator of italis and bold attributes, which are not changes, only the font size is indicated. | ||
[[File:DealCardsFreeCellOutput1.png|border]] | [[File:DealCardsFreeCellOutput1.png|border]] |
Revision as of 11:40, 29 March 2019
This page is the answer to the task Creating Deal cards for FreeCell in the Rosetta Code.
Contents
Description (from Rosetta Code)
Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.) As the game became popular, Jim Horne disclosed the algorithm, and other implementations of FreeCell began to reproduce the Microsoft deals. The algorithm uses this linear congruential generator from Microsoft C:
The algorithm follows:
Deals can also be checked against FreeCell solutions to 1000000 games. (Summon a video solution, and it displays the initial deal.) Write a program to take a deal number and deal cards in the same order as this algorithm. The program may display the cards with ASCII, with Unicode, by drawing graphics, or any other way. |
Program
Explanation
There is no need to remove from a deal to be added to another one, it can be performed on a single array. It is and iteration from 52 to 1 indicating the end of the first array, and therefore the start of a second one after each swap. The only inconvenience is that second array contains the information in reversed order, but when it is shown it is also read in reversed order.
The number 127,185 is the decimal number of the 🃑 Unicode character.
In the Unicode playing cards characters, there is the Knight, between the Jack and Queen suits, which is not used, so it is skipped in the order.
Case 1. Deal #1
In order to show the result in bigger characters, we use the SetFont
expression. The Null expressions are the font name, the indicator of italis and bold attributes, which are not changes, only the font size is indicated.