This page contains a working example of how to use the Anarchy Library, using the JavaScript version of the library. You can view the source code of this page to see how the code is written.
Right: A basic example showing how to use the shuffling interface
You can enter a numerical seed value and hit shuffle to pick a specific shuffle,
or just hit next to increment the seed and re-shuffle.
Here's the core function that does the shuffle:
//Creates RNG that shuffles the deck using
cohort_shuffle
function
shuffle_deck(
seed
) {
//delete previous shuffle
table.innerHTML =
"" ;
for (
let
i = 0;
i <
myDeck.length; ++
i) {
//Use anarchy to get index
let
index =
anarchy
.rev_cohort_shuffle(
i, myDeck.length, seed);
//adding card elmt to table
let
card =
myDeck[index];
let
elm =
document.
createElement("div");
elm.classList.add(
"suit_" + card.suit);
elm.innerHTML.add(
"<span class = 'number'>" +
card.name +
"</span><span class = 'suit'>" +
card.suit +
"</span>");
table.appendChild(
elm):
}
}