CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements...
Transcript of CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements...
![Page 1: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/1.jpg)
11/28/2016
CS 259 Computer Programming
Fundamentals
Diffusion-Limited Aggregation
Instructor:
Joel Castellanos
e-mail: [email protected]
Web: http://cs.unm.edu/~joel/
![Page 2: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/2.jpg)
2
Diffusion-Limited Aggregation
Start with an immobile seed in a 2D, square grid.
A walker is then launched from a random
position far away and is allowed to diffuse by
moving one grid space in a random direction
each time step.
If the walker touches the seed, it is immobilized
instantly and becomes part of the aggregate.
Similar walkers are launched one-by-one and
each of them stops upon hitting the cluster.
Try imagining what the result of this process....
![Page 3: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/3.jpg)
2D Diffusion-Limited Aggregation
3
![Page 4: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/4.jpg)
4
3D Diffusion-Limited Aggregation
By Mark Stock By Simon Chorley
![Page 5: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/5.jpg)
Pyrolusite: Manganese Dioxide, MnO2
5
Photo: wanderflechten of
Flickr.com under Creative
Commons license
Photo: Professor George R.
Rossman, Dept Geology, Caltech
![Page 6: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/6.jpg)
6
Manganese Dioxide Dendrites on Limestone
Photograph by Mark A. Wilson (Department of Geology, The College of Wooster).
![Page 7: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/7.jpg)
7
Copper Crystal
Copper Crystallization from Copper Sulfate Solution
![Page 8: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/8.jpg)
DLA: (1 of 2)
Create DLA_yourName.java that implements Diffusion-
Limited Aggregation on a 2D, 800x800 grid of pixel.
Initialize the grid with one seed crystal in an interesting spot.
Also create n particles in random locations along the bottom.
Each timestep, every non-crystalized particle moves, with
equal probability, north, south, east or west by one pixel.
If a particle moves out of the window, then reset its location,
to a random spot along the bottom.
8
![Page 9: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/9.jpg)
Lab 4 DLA: (2 of 2)
If a particle moves adjacent (by whatever definition you were
assigned) to a crystalized particle, then the moving particle
crystalizes:
a) Draw it in a color determined by whatever rules you have
coloring.
b) Sets it x and y values to a random location along the bottom.
Moving particles may pass through each other.
All the colors must look good together.
9
![Page 10: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/10.jpg)
10
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 5 1 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
int[][] grid = new int[15][9]
grid[2][1] = 1;
grid[1][1] = 5;
Creating and Using a 2D Array
![Page 11: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/11.jpg)
Individualized Assignments
color by age
color by
neighbor count
within radius of
2
Stop on edge (N, S, E, W) Stewart Moses
Stop on corner (NW, NE, SW, SW) Ryan Rafael
Stop on edge or corner (all 8 directions) tomas, Winston Jacob, bugra
Layers (6 faces) Color by depth Zeke, Ben
Layers (26 faces and edges and corners)
Color Depth Jay, Bryant
Automatic change of most likly
face/edge/corner Jarett
11
![Page 12: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/12.jpg)
Stop on edge or corner (all 8 directions)
12
0 1 2 3 4 5 6
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0
3 0 0 0 1 0 0 0
4 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0
2,5
5,0
4,4
![Page 13: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/13.jpg)
Stop on edge or corner (all 8 directions)
13
0 1 2 3 4 5 6
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0
3 0 0 0 1 0 0 0
4 0 0 0 0 1 0 0
5 0 0 0 0 0 0 0
2,5
5,0
4,5
private static final int[] dx = {1, 0, -1, 0};
private static final int[] dy = {0, 1, 0, -1};
![Page 14: CS-150L – Lab 12joel/cs259/notes/CS-259...DLA: (1 of 2) Create DLA_yourName.java that implements Diffusion- Limited Aggregation on a 2D, 800x800 grid of pixel. Initialize the grid](https://reader036.fdocuments.us/reader036/viewer/2022071421/611bab0f1b045a5941381b11/html5/thumbnails/14.jpg)
Stop on edge
14
0 1 2 3 4 5 6
0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
2 0 0 0 8 0 0 0
3 0 0 0 1 8 0 0
4 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0