Nodes/ComfyUI-LifeGame/生命游戏动画
ComfyUI Node

生命游戏动画

The Game of Life node that renders real frames, GPU not required

By assemly·Created about a year ago·Updated about a year ago· 2
生命游戏动画
    • images
    • final_state
    width100
    height100
    cell_size5
    frames30
    modepreset
    presetglider
    density0.3
    alive_color#FFFFFF
    dead_color#000000
    x_offset
    y_offset

    Some custom nodes are about squeezing quality out of a model. This one is not. LifeGameAnimation runs Conway's Game of Life on a grid and hands you a batch of actual IMAGE frames - deterministic, two-color, zero diffusion involved. Your GPU sits this one out; it's pure numpy on CPU.

    Why would you want that in ComfyUI? The frames aren't for looking at raw. They're for feeding the rest of the graph. Wire the images output into a video save node (the pack's own LifeGameSaveAnimation is the natural partner) for a looping animated GIF, pipe it into an img2video model as a starting reference, or use it as a test input for any node that consumes image batches. Think of it as a controllable animation-source node for a world most of ComfyUI never touches: procedural graphics rather than sampled pixels.

    How it works

    The node creates a LifeGame instance with your width × height grid, seeds it, then renders a frame, advances the automaton one step, renders again - frames times total. Each frame is drawn as flat color: alive cells get alive_color, everything else gets dead_color, scaled up so one cell is cell_size pixels.

    One mechanism detail worth knowing: the grid is toroidal. The update() step uses numpy's np.roll, which wraps cells around the edges. That means patterns like the glider or Gosper gun don't die at the border - they wrap to the other side. Great for infinite loops, slightly weird if you expected a hard wall.

    The inputs that actually matter

    Nine inputs looks like a lot, but you set two things and forget the rest:

    • mode (preset/random) and preset - the one-two punch. Presets are classic Game of Life patterns: glider, blinker, toad, beacon, pulsar, gosper_glider_gun, diehard, acorn, lightweight_spaceship, r_pentomino, infinite_growth, glider_gun, line_puffer. Default glider is fine to start; gosper_glider_gun or r_pentomino are the fun ones for animation.
    • width, height, cell_size, frames - grid size in cells, pixels per cell, and number of frames. Defaults (100×100, cell 5, 30 frames) give you a 500×500 GIF.

    Everything else: density only matters in random mode (0.3 default, how packed the random seed is), alive_color/dead_color are hex strings (#FFFFFF/#000000), and the optional x_offset/y_offset nudge where a preset lands. The final_state output is a LIFEGAME_STATE object - informational, nothing else in the pack reads it.

    Installing it

    It's a small pack with no models to download. ComfyUI Manager can find it as comfyui-lifegame, or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/assemly/comfyui-lifegame
    pip install -r requirements.txt
    

    Then restart ComfyUI and look in the 生命游戏 (Game of Life) category. Dependencies are just numpy, Pillow, and aiohttp - you almost certainly already have all three.

    Gotchas

    • Random mode has no seed input. There's no seed widget anywhere in the schema, so random runs aren't reproducible. If you need the same pattern twice, use a preset instead.
    • Mind the max bounds. The sliders go to width/height 500 with cell_size 20 - that's 10,000-pixel-tall frames, times up to 300 frames, in float32. The defaults are light, but maxing the extremes is a fast path to OOM. Keep cell_size modest.
    • Offsets only apply if you set both. The code checks x_offset and y_offset together; supplying just one silently ignores it.

    The name is a small lie: this isn't an AI node at all, and that's exactly why it's reliable. Deterministic, instant, and a genuinely fun way to make looping test footage.

    Category生命游戏

    Inputs (11)

    NameTypeDefaultDescription
    widthINT10020–500
    heightINT10020–500
    cell_sizeINT51–20
    framesINT301–300
    modeCOMBOpreset2 options: preset, random
    presetCOMBOglider13 options: glider, blinker, toad, beacon, pulsar, gosper_glider_gun, +7
    densityFLOAT0.30.1–0.9
    alive_colorSTRING#FFFFFF
    dead_colorSTRING#000000
    x_offsetoptINT0–500
    y_offsetoptINT0–500

    Outputs (2)

    NameTypeDescription
    imagesIMAGE
    final_stateLIFEGAME_STATE