Skip to content

dkoneill/millershuffle_berry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

the Miller Shuffle Algorithm in Berry

This is a port of the Miller Shuffle Algorithm to the Berry scripting language as embedded into Tasmota. The port was performed by sfromis and posted in this Tasmota discussion thread.

Usage

Upload millershuffle.be into the Tasmota file system under Consoles -> Manage File Systems, then the import in the code sample below will work.

import millershuffle
var ms = millershuffle.create(123,100)  # shuffleID 123, listSize 100
print(ms.random())                      # next random number in shuffle sequence
print(ms.random(8))                     # reset index in sequence and get random number

Doing a speed comparison with math.rand(), a simple loop summing 2000 numbers took 160 ms vs 46 ms on an ESP32-C3. The speed of this should be fine for most purposes.

About

the Miller Shuffle Algorithm in Berry

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages