π² Random Bool
A Weighted Coin Flip for Your Graph
- random_bool
π² Random Bool outputs True or False. That's it. The reason it's in the pack - and the reason it's more useful than it sounds - is that a BOOLEAN output is a routing decision, and ComfyUI's switch nodes take exactly that. Flip a boolean and you've flipped a whole branch of the graph: hires-fix on or off, two different upscalers, an inpaint pass that runs maybe half the time.
The other half of the point is true_probability. A 50/50 coin is fine, but 0.8/0.2 is a coin that mostly does the thing you like - which is how you get variety in a batch without the batch being half garbage.
How it works
Set true_probability between 0.0 (never) and 1.0 (always); the node compares a random draw against it. seed is optional and defaults to -1. With seed >= 0 it creates a local random.Random(seed) and rolls from that, so the same seed gives the same result every time - useful for reproducing a batch, and for A/B testing where the only thing you want to change is one branch. With seed = -1 it draws from Python's module-level RNG, i.e. a fresh roll each time it executes.
That last qualifier matters in ComfyUI, which caches aggressively: a node whose inputs didn't change can be served from cache instead of re-executing, and unlike this pack's plain Random Seed node (which pins a fingerprint_inputs of time.time() to force a re-run every execution), the seeded random nodes don't. If your -1 roll appears stuck on the same value, that's the cache, not the dice. Change something upstream, or set an explicit seed and increment it yourself.
Inputs and outputs
One required input, true_probability, and the optional seed. One output, random_bool, typed BOOLEAN. It's a direct input to A/B switch nodes and to any node with a boolean widget you've converted to an input.
There's no visual feedback - no console print, no preview. If you want to know what it rolled, wire it to a text or note node, or check downstream behaviour. Slightly annoying, but it keeps the node cheap in a batch.
Install
ComfyUI Manager β search "ComfyUI-mnemic-nodes" β install β restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
The pack's requirements.txt installs a fistful of packages (transformers, opencv-python, tiktoken, piexif, tqdmβ¦) for its other nodes; this one is pure Python and needs none of them. No models, no API keys.
Common issues
Everything downstream runs the same branch every time. Either the probability is effectively 0 or 1, or you've set a fixed seed and are queueing the same prompt with the same inputs - see the caching note above.
The switch node won't accept it. ComfyUI is strict about types. A BOOLEAN output goes into a boolean input; if your switch wants an integer index, you'll need something to convert it, or a different switch.
Same branch twice in a row. Expected. Independent draws repeat. If you need strict alternation, that's a counter, not a coin - a different tool.
It's genuinely random, so batches are lumpy. Ten runs at 0.5 is not five and five. If your workflow has a slow branch, unlucky streaks are how you find out.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| true_probability | FLOAT | 0.500β1 | Probability of returning True (0.0 = always False, 1.0 = always True, 0.5 = 50/50). |
| seedopt | INT | -1-1β18446744073709550000 | Seed for random number generator. Use -1 for random seed (different each time), or set a specific value for reproducibility. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| random_bool | BOOLEAN | The rolled value: True with the probability set above. |