Nodes/petty-paint-comfyui-node/PPGenerateRandomNumber
ComfyUI Node

PPGenerateRandomNumber

Roll a fresh integer every run — great for seeds, lousy for reproducibility

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
PPGenerateRandomNumber
    • random_number
    min_value0
    max_value100

    Seeds are where a lot of workflows go to die. You hardcode one, every run looks the same; you leave the default, and half the time you're not sure what you're comparing. PPGenerateRandomNumber is the pack's answer: give it a min and a max, and it hands back a random integer on every single execution. Hook it into your seed input and each queue gives you a genuinely different starting point with zero bookkeeping.

    How it works

    Two INT inputs - min_value (default 0) and max_value (default 100) - and the node calls random.randint(min, max), an inclusive draw: both bounds are valid outcomes. The result exits as the random_number output, typed INT, and will happily feed any integer input in the graph: the seed port on a KSampler, a step count, a PPSelectRandomValue index, an iteration limit.

    The deliberate behavior here is in the IS_CHANGED override, which always returns True. ComfyUI therefore treats this node as changed on every execution, meaning you get a fresh value each queue - no caching of "the last random number I rolled." That's exactly what you want for a seed generator, and it has the side effect of re-running anything downstream that consumes it, every time.

    The trade-off, stated plainly

    There's no seed input, and there's no way to reproduce a number. That's the point of the node - but it's also the trap. The moment you generate something you love and want to recreate it, you can't from this node alone; the value that produced the image is sitting in that run's workflow data only if you captured it. If reproducibility matters, hardcode a seed you like and only switch to this node when you're deliberately exploring. For "roll me a bunch of variants and I'll keep the good one," it's ideal.

    Installing it

    Same as every node in this pack - it comes with the petty-paint install. ComfyUI Manager search "Petty Paint", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mephisto83/petty-paint-comfyui-node
    

    then restart ComfyUI. No models to download; the pack's only pinned dependency (Flask) isn't actually imported by the current source, so the install stays small.

    Where it fits

    In the petty-paint loop it's the companion to PPGenerateRandomFloat - that one rolls floats for CFG/denoise, this one rolls integers for seeds and indexes. If you need a random pick from a list instead of a raw number, PPSelectRandomValue is your node. Use this one for anything where "a different integer every run" is the goal and you'll never think about it again.

    CategoryPettyPaint

    Inputs (2)

    NameTypeDefaultDescription
    min_valueINT0
    max_valueINT100

    Outputs (1)

    NameTypeDescription
    random_numberINT