Brownian tree

You are encouraged to solve this task according to the task description, using any language you may know.



Task

Generate and draw a   Brownian Tree.



A Brownian Tree is generated as a result of an initial seed, followed by the interaction of two processes.

 The initial "seed" is placed somewhere within the field. Where is not particularly important; it could be randomized, or it could be a fixed point.
 Particles are injected into the field, and are individually given a (typically random) motion pattern.
 When a particle collides with the seed or tree, its position is fixed, and it's considered to be part of the tree.

Because of the lax rules governing the random nature of the particle's placement and motion, no two resulting trees are really expected to be the same, or even necessarily have the same general shape. 



BEGIN
    INTEGER NUM_PARTICLES;
    INTEGER LINES, COLUMNS;
    INTEGER SEED;
 
    NUM_PARTICLES := 1000;
    LINES := 46;
    COLUMNS := 80;
    SEED := ININT;
    BEGIN
 
        PROCEDURE DRAW_BROWNIAN_TREE(WORLD); INTEGER ARRAY WORLD;
        BEGIN
            INTEGER PX, PY;  COMMENT PARTICLE VALUES ;
            INTEGER DX, DY;  COMMENT OFFSETS ;
            INTEGER I;
 
            COMMENT SET THE SEED ;
            PX := RANDINT(0,LINES-1,SEED);
            PY := RANDINT(0,COLUMNS-1,SEED);
            WORLD(PX,PY) := 1;
 
            FOR I := 0 STEP 1 UNTIL NUM_PARTICLES - 1 DO BEGIN
                COMMENT SET PARTICLE'S INITIAL POSITION ;
                PX := RANDINT(0,LINES-1,SEED);
                PY := RANDINT(0,COLUMNS-1,SEED);
 
                WHILE TRUE DO BEGIN
                    COMMENT RANDOMLY CHOOSE A DIRECTION ;
                    DX := RANDINT(-1,1,SEED);
                    DY := RANDINT(-1,1,SEED);
 
                    IF DX + PX < 0 OR DX + PX >= LINES
                    OR DY + PY < 0 OR DY + PY >= COLUMNS THEN
                    BEGIN
                        COMMENT PLOP THE PARTICLE INTO SOME OTHER RANDOM LOCATION ;
                        PX := RANDINT(0,LINES-1,SEED);
                        PY := RANDINT(0,COLUMNS-1,SEED);
                    END ELSE IF WORLD(PX + DX, PY + DY) <> 0 THEN BEGIN
                        COMMENT BUMPED INTO SOMETHING ;
                        WORLD(PX, PY) := 1;
                        GO TO BREAK;
                    END ELSE BEGIN
                        PY := PY + DY;
                        PX := PX + DX;
                    END IF;
                END WHILE;
                BREAK:
            END FOR;
        END DRAW_BROWNIAN_TREE;
 
        INTEGER ARRAY WORLD(0:LINES-1,0:COLUMNS-1);
        INTEGER I,J;
 
        DRAW_BROWNIAN_TREE(WORLD);
 
        FOR I := 0 STEP 1 UNTIL LINES-1 DO
        BEGIN
            FOR J := 0 STEP 1 UNTIL COLUMNS-1 DO
            BEGIN
                OUTCHAR(IF WORLD(I,J)=0 THEN '.' ELSE '*');
            END;
            OUTIMAGE;
        END;
 
    END;
END.