dimanche 17 juillet 2022

I can't understand how this script functions

Card shuffling script

After both for loops have finished, have all the cards been labelled before function c has been started? card1=2D card2=2C Card3=2H............... Card52=AS

If that is how it works , how does it randomise them ?

The random number range is reduced by 1 after enter is pressed , if card52 hasn't been been picked , how can it be picked if the range is now 51?

@echo off
title
rem %random%

setlocal enabledelayedexpansion

set a=0
set e=52
set f=0
for %%a in (2 3 4 5 6 7 8 9 10 J Q K A) do call :a "%%a"
goto c
:a arg1
set b= %~1
for %%b in (%~1D%b%C%b%H%b%S) do call :b "%%b"
exit /b 0
:b arg1
set /a a=a+1
set Card%a%=%~1
exit /b 0


:c
set /a c=%random%*%e%/32768+1
set d=!Card%c%!
set /a f=%f%+1
echo Card #%f%: %d%
echo.
pause
cls
set Card%c%=!Card%e%!
set /a e=%e%-1


if %e% neq 0 goto c
Pause
exit



Aucun commentaire:

Enregistrer un commentaire