Batch Randomization

so how do you make randomized scenarios in batch because im making a text based game where i need random scenarios like for example get a random customer for a shop game or random skeleton appearing with a randomized amount of hp that you can set.

g-one10 days ago

@echo off &setlocal

set "customer_1=Peter"

set "customer_2=Paul"

set "customer_3=Mary"

set /a "rnd=%random% %% 3 + 1"

call echo %%customer_%rnd%%%

pause

%random% expands to a number between 0 and 32768. To calculate a number in range 1...3 use the modulus operator (%%) with divisor 3 and add 1.

To expand a nested variable you can use CALL and double the outer percent signs of the variable.