How to resolve the algorithm Deal cards for FreeCell step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Deal cards for FreeCell step by step in the Run BASIC programming language

Table of Contents

Problem Statement

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. These deals are numbered from 1 to 32000. Newer versions from Microsoft have 1 million deals, numbered from 1 to 1000000; some implementations allow numbers outside that range. 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. Related tasks:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Deal cards for FreeCell step by step in the Run BASIC programming language

Source code in the run programming language

projectDir$	= "a_project"                                            ' project directory
imageDir$ 	= DefaultDir$ + "\projects\" + projectDir$ + "\image\"   ' directory of deck images
imagePath$	= "../";projectDir$;"/image/"                            ' path of deck images

suite$ = "C,D,H,S"                                                       ' Club,Diamond,Heart,Spades
card$  = "A,2,3,4,5,6,7,8,9,T,J,Q,K"                                     ' Cards Ace to King

dim n(55)                                                                ' make ordered deck 
for i = 1 to 52                                                          '  of 52 cards
 n(i) 	= i
next i

for i = 1 to 52 * 3                                                      ' shuffle deck 3 times
  i1    = int(rnd(1)*52) + 1
  i2    = int(rnd(1)*52) + 1
  h2    = n(i1)
  n(i1) = n(i2)
  n(i2) = h2
next i

for yy = 1 to 8                                                        ' display 7 across and 8 down
  for xx = 1 to 7
    card = card + 1
    s    = (n(card) mod 4)  + 1                                        ' determine suite
    c    = (n(card) mod 13) + 1                                        ' determine card
    cardId$ = word$(card$,c,",");word$(suite$,s,",");".gif"
    html "
" html "" html "
" if card = 52 then end ' out of cards next xx next yy

You may also check:How to resolve the algorithm Taxicab numbers step by step in the Elixir programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Blue programming language
You may also check:How to resolve the algorithm Deepcopy step by step in the Factor programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Vedit macro language programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the M4 programming language