Using a virtual deck, the cards in order can be dealt in random order,
no longer requiring any method of shuffling.
============================================================================
SCREEN 0
CLS
deckofcards$ = "As 2s 3s 4s 5s 6s 7s 8s 9s 10sJs Qs Ks Ac 2c 3c 4c 5c 6c 7c 8c 9c 10cJc Qc Kc Ad 2d 3d 4d 5d 6d 7d 8d 9d 10dJd Qd Kd Ah 2h 3h 4h 5h 6h 7h 8h 9h 10hJh Qh Kh " ' this is the full deck
numberofplayers% = 0
WHILE numberofplayers% < 1 OR numberofplayers% > 5
LOCATE 3, 3
INPUT " Enter the Number of Players (1-5):"; numberofplayers%
WEND
cardstodeal% = 0
maxcardstodeal% = INT(52 / numberofplayers%)
WHILE cardstodeal% < 1 OR cardstodeal% > maxcardstodeal%
LOCATE 4, 3
PRINT "Enter the Number of Cards to Deal (1-"; maxcardstodeal%; "):";
INPUT cardstodeal%
WEND
player$ = "Player 1 Player 2 Player 3 Player 4 Player 5"
LOCATE 6, 4: PRINT LEFT$(player$, 15 * numberofplayers%)
under$ = "-------- -------- -------- -------- -------- "
LOCATE 7, 4: PRINT LEFT$(under$, 15 * numberofplayers%)
RANDOMIZE TIMER
FOR l1% = 1 TO cardstodeal%
FOR l2% = 1 TO numberofplayers%
selection% = INT(RND * LEN(deckofcards$) / 3 + 1) * 3 - 2 ' pick a card
z$ = MID$(deckofcards$, selection%, 3)
LOCATE 7 + l1%, 15 * l2% - 8: PRINT z$
deckofcards$ = LEFT$(deckofcards$, selection% - 1) + MID$(deckofcards$, selection% + 3, LEN(deckofcards$) - selection%) ' remove the selected card from the deck = shrink the deck
NEXT l2%,l1%
PRINT : PRINT
PRINT TAB(6); "Remaining cards in the deck: ";
IF deckofcards$ = "" THEN PRINT "None" ELSE PRINT deckofcards$
END |