?`w?´nrín 0011

The Chance — Random Numbers

Methods

random / pese / laileto

Owonrin.random(min?, max?) ? Int

Generate random integer. Default range 0-100.

// Random 0-100
ayanmo n = Owonrin.random();

// Random 1-10
ayanmo dice = Owonrin.random(1, 6);

// Random 0-max
ayanmo percent = Owonrin.random(0, 100);

shuffle / rudurudu

Owonrin.shuffle(list: List) ? List

Randomly shuffle list elements.

ayanmo cards = [1, 2, 3, 4, 5];
ayanmo shuffled = Owonrin.shuffle(cards);
Irosu.fo(shuffled);

pick / yan

Owonrin.pick(list: List) ? Any

Pick random element from list.

ayanmo colors = ["red", "green", "blue"];
ayanmo choice = Owonrin.pick(colors);
Irosu.fo("Selected:");
Irosu.fo(choice);

Example: Dice Game

// Simple dice game
Irosu.fo("Rolling dice...");

ayanmo player = Owonrin.random(1, 6);
ayanmo computer = Owonrin.random(1, 6);

Irosu.fo("You rolled:");
Irosu.fo(player);
Irosu.fo("Computer rolled:");
Irosu.fo(computer);

ti (player > computer) {
    Irosu.fo("You win!");
} bib?k? ti (player < computer) {
    Irosu.fo("Computer wins!");
} bib?k? {
    Irosu.fo("Tie!");
}