Search HoldMyTwist

Browse all posts

Episode 33

The Puddle Across the Corner

Duck attempts to colour corner adjacent puddles. Two neighbour rules give different fills. One bridge tile changes which cells are reachable for the brush.

Episodes

Computing Basics

    Duck has a paint wand in front of a 3x3 grid. The top-left, center and bottom-right cells are water (seed in top-left).
    Start from the upper left, blue square. Only fill in original blue squares, not white background.
    Duck points in top-left-centre water cells. They only touch at a corner, all other nearby cells are background.
    Robot points to the grid & seed in top-left. Duck stops to think how many water cells are in a 4-neighbour fill.
    Duck colours top left seed, rest of water cells (centre and bottom right) are still blue. Robot counts one reached cell.
    Only the top left seed is filled.
    fresh copy of the original diagonal water grid
    Robot shows eight neighbours directions(incl. 4 diagonals). Duck is following one of corner arrows.
    Duck goes into top left/centre with a diagonal step. Bottom right water cell not filled in yet (until next step)
    Robot draws next diagonal line going from center to bottom right. Duck takes 3rd water cell. No changes in background cells.
    This shows the result of two fills of the same original grid. Four neighbour fill filled one cell. Eight neighbour fill filled all three water cells.
    Robot is pointing to the new unpainted cells on both boards. Duck is not going to paint those cells because he can only paint the original water cells.
    Duck adds top-middle (one water cell) to a new practice grid. Robot is on the counts. Duck predicts the two neighbour rules with a common top-left seed.
    Duck is tracking edges shared across the top-left, top-middle and centre. Those 3 cells are getting filled, but bottom-right stays blue.
    Duck has an individual 8 neighbour fill on the practice grid. It goes diagonally down to the bottom right and fills all four water cells.
    Duck has an extra bridge-tile next to the two practice results. Robot compares three reached cells (four-neighbour) and four reached cells (eight-neighbour).

    Episode transcript

    A corner-touching puddle

    Duck has a paint wand in front of a 3x3 grid. The top-left, center and bottom-right cells are water (seed in top-left).

    Diagram values: 100; 010; 001; SEED (0,0)

    Duck: I want all my little puddles to be one click to colour.

    Start from the upper left, blue square. Only fill in original blue squares, not white background.

    Diagram values: 4: UP DOWN LEFT RIGHT; BLUE 1 / WHITE 0; GRID: 100 / 010 / 001; SEED TOP-LEFT (0,0)

    Robot: First, you have to figure out what a neighbour is.

    Duck points in top-left-centre water cells. They only touch at a corner, all other nearby cells are background.

    Diagram values: (0,0) ↘ (1,1)

    Duck: The next blue one is adjacent at only a corner of my square.

    Robot points to the grid & seed in top-left. Duck stops to think how many water cells are in a 4-neighbour fill.

    Diagram values: 4-NEIGHBOUR

    Robot: How many cells are reached by four-neighbour fill?

    Only shared edges

    Duck colours top left seed, rest of water cells (centre and bottom right) are still blue. Robot counts one reached cell.

    Diagram values: X00; 010; 001; COUNT 1

    Duck: Just the first one. no shared edge with any water cell.

    Only the top left seed is filled.

    Diagram values: UNCHANGED (1,1),(2,2)

    Robot: The reason that these two are still blue is that there is no edge path from the seed to them.

    fresh copy of the original diagonal water grid

    Diagram values: RESET COPY

    Duck: Same puddles. Different game. Let's start over.

    Robot shows eight neighbours directions(incl. 4 diagonals). Duck is following one of corner arrows.

    Diagram values: 8: EDGES + CORNERS

    Robot: Ok, allow for all diagonals.

    Allow the diagonals

    Duck goes into top left/centre with a diagonal step. Bottom right water cell not filled in yet (until next step)

    Diagram values: X00; 0X0; 001

    Duck: I can go to the center square now from the corner.

    Robot draws next diagonal line going from center to bottom right. Duck takes 3rd water cell. No changes in background cells.

    Diagram values: X00; 0X0; 00X; COUNT 3

    Robot: From the middle goes another diagonal to the last square.

    This shows the result of two fills of the same original grid. Four neighbour fill filled one cell. Eight neighbour fill filled all three water cells.

    Diagram values: 4 → 1 CELL; 8 → 3 CELLS

    Duck: Eight neighbour fill will affect all three water cells.

    Robot is pointing to the new unpainted cells on both boards. Duck is not going to paint those cells because he can only paint the original water cells.

    Diagram values: ONLY ORIGINAL 1 CELLS

    Robot: Flood fill starting at seed tries to fill all connected eligible cells. It doesn't do a background jump.

    Build one bridge

    Duck adds top-middle (one water cell) to a new practice grid. Robot is on the counts. Duck predicts the two neighbour rules with a common top-left seed.

    Diagram values: 110; 010; 001

    Duck: Add water in top-middle box. How far do the rules go now?

    Duck is tracking edges shared across the top-left, top-middle and centre. Those 3 cells are getting filled, but bottom-right stays blue.

    Diagram values: XX0; 0X0; 001; COUNT 3

    Robot: Go one to the right then go one down. That's the middle.

    Duck has an individual 8 neighbour fill on the practice grid. It goes diagonally down to the bottom right and fills all four water cells.

    Diagram values: XX0; 0X0; 00X; COUNT 4

    Duck: With diagonals it reaches the lower-right cell too. They all fill.

    Duck has an extra bridge-tile next to the two practice results. Robot compares three reached cells (four-neighbour) and four reached cells (eight-neighbour).

    Diagram values: 4 → 3 CELLS; 8 → 4 CELLS

    Robot: 4-neighbor fill covers three water cells. 8-neighbor fill covers all four water cells.

    The lesson

    Diagram values: ORIGINAL 100/010/001; SEED TOP-LEFT; 4-NEIGHBOUR: 1 CELL, INCLUDING SEED; 8-NEIGHBOUR: 3 CELLS, INCLUDING SEED

    It will fill the seed and all connected valid cells. In this case only the initial cells that are 1 are valid. Anything that is 0 is background. A four neighbour move has a common edge. Eight neighbour move may have common corner too. Eight neighbour fill will affect all three water cells. Neither will step on invalid background. These are discrete grid rules. They aren't a water flow physical model.

    Try it

    Diagram values: 110; 000; 011; SEED (0,0); ONLY ORIGINAL 1 CELLS

    Use the new 3*3 grid 110/000/011. Start with top left water cell and mark only the cells labeled one. How many cells do the different neighbor rules fill? How does the empty middle row affect it?

    Answer

    Both rules can only touch those 2 water cells in the top row. The entire middle row is empty, and it blocks the 2 water cells in the bottom row. 8-neighbour fill does include direct diagonal neighbours, but it cannot "skip" a full row of background in between, so both are 2.

    Sources

    SciPy documentation: connected features and diagonal connectivity (opens in a new tab)