diff --git a/nvim/.config/nvim/lua/plugins/alpha.lua b/nvim/.config/nvim/lua/plugins/alpha.lua index 400e970..199b9a6 100644 --- a/nvim/.config/nvim/lua/plugins/alpha.lua +++ b/nvim/.config/nvim/lua/plugins/alpha.lua @@ -4,7 +4,7 @@ local function clamp(x, min, max) return math.max(math.min(x, max), min) end local function get_random_image() - images = { + local images = { { [[██╗ █████╗ ██████╗██╗ ██╗███████╗]], [[██║ ██╔══██╗██╔════╝██║ ██║██╔════╝]], @@ -29,21 +29,53 @@ local function get_random_image() [[██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║]], [[██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║]], [[╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝]] + }, + { + [[ ▄ ]], + [[ ▟█▙ ]], + [[ ▟███▙ ]], + [[ ▟█████▙ ]], + [[ ▟███████▙ ]], + [[ ▂▔▀▜██████▙ ]], + [[ ▟██▅▂▝▜█████▙ ]], + [[ ▟█████████████▙ ]], + [[ ▟███████████████▙ ]], + [[ ▟█████████████████▙ ]], + [[ ▟███████████████████▙ ]], + [[ ▟█████████▛▀▀▜████████▙ ]], + [[ ▟████████▛ ▜███████▙ ]], + [[ ▟█████████ ████████▙ ]], + [[ ▟██████████ █████▆▅▄▃▂ ]], + [[ ▟██████████▛ ▜█████████▙ ]], + [[ ▟██████▀▀▀ ▀▀██████▙ ]], + [[ ▟███▀▘ ▝▀███▙ ]], + [[▟▛▀ ▀▜▙]], + [[ btw ]] } } - local i = 3 + local pmf = {0.25, 0.25, 0.25, 0.25} + local cdf = {} - math.randomseed(os.time()) - if math.fmod(math.random(100), 5) == 0 then - if math.random(0, 1) == 0 then - i = 1 - else - i = 2 - end + cdf[1] = 0 + for j = 2, #pmf+1 do + cdf[j] = cdf[j - 1] + pmf[j - 1] end - return images[i] + if math.abs(cdf[#cdf] - 1) > 0.01 then + error("Probabilities do not add up to 1") + elseif #images ~= #pmf then + error("Number of images and probabilities do not match") + end + + math.randomseed(os.time()) + local r = math.random(100) + + for j = 2, #cdf do + if r <= cdf[j] * 100 then + return images[j-1] + end + end end -----------------