Nodes/ComfyUI-Games/Snake Game
ComfyUI Node

Snake Game

Snake, but it lives inside your diffusion workflow

By GraftingRayman·Created 8 months ago·Updated 2 months ago· 0
Snake Game
  • image
  • IMAGE

The SnakeNode from ComfyUI-Games is exactly what it sounds like: a playable Snake game rendered as a canvas widget inside a ComfyUI node, so you can relive 2003 while a 30-step KSampler eats your GPU. It's the most low-commitment of the pack's six games - no boards to learn, no brick layouts, just a snake, an apple, and arrows. You'll play it, you'll die, you'll hit Queue again and play it more.

What it actually does - and what it doesn't

Read the Python and you'll think the author shipped a stub:

def play_snake(self, image):
    return (image,)

That's the entire backend. The node takes an image tensor, returns it unchanged, and the real game lives in web/js/snake.js, which hooks the node on creation and drops a canvas into it. Everything - the 20×20 grid, the food, the growing tail, the death screen - happens in your browser, on a DOM canvas. The tensor never sees any of it.

So two truths follow. First, the game only exists when you're looking at the workflow in the UI; an API run just passes the image through. Second, and this is the trap people walk into: your input image is not the game board. Feed it your prettiest render and Snake will ignore it completely and draw its own grid. The image input is there so the node has something to wire in - think of it as a passenger seat, not a steering wheel.

What you get to play

The input/output surface is minimal, straight from the info_schema:

  • Input: image (IMAGE, required) - passed through untouched.
  • Output: IMAGE - same tensor, bit for bit.

All the real choices live in the widget. Snake ships three modes - classic, walls (bounce off the walls rather than die), and obstacles (rocks spawn in the arena) - and the grid doubles to 40×40 in one of them for that "4× cubes" feel. Controls are arrow keys (or WASD, the usual suspects), the game auto-saves your best score to snake_highscore.json in the pack folder via ComfyUI's own server, and that's genuinely the whole feature list.

Installing ComfyUI-Games

One pack, six games, one install. Use ComfyUI Manager and search for ComfyUI-Games, or:

cd ComfyUI/custom_nodes
git clone https://github.com/GraftingRayman/ComfyUI-Games

Restart ComfyUI and you're done. There's no requirements.txt to fight with and no model download - the only server-side dependency is aiohttp, which ComfyUI already has. Compare that to the average node pack's dependency hell and this one installs like a dream.

Common issues

  • "Why isn't my image on the screen?" Because it was never going to be. Passthrough, remember?
  • High score lost after a git pull. Scores live in plain JSON in custom_nodes/ComfyUI-Games/; overwriting the folder resets them.
  • Arrow keys doing double duty. Snake grabs global key listeners, so ComfyUI's own shortcuts can misfire while a game is live. They're cleaned up when you delete the node.
  • Red text spam at startup. The pack prints a colored "Node Loaded" line for each of its six games. Harmless.

It's a toy. It knows it's a toy. But it's a zero-dependency, zero-VRAM toy that makes waiting on a render feel like a decision you made, and that's worth more than it sounds.

Categorygames

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE