25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Payments   Humor   Music  

Diffusion limited aggregation simulation in GWBASIC / BASICA

DLA3.BAS simulates diffusion limited aggregation. A particle wanders around on the screen. When it hits the border of its enclosure or another particle, it sticks to it, gradually building a lacy fractal shape.

It was written in GWBASIC for the Heathkit H-100 computer. I suspect it should run in BASICA on any PC compatible after enabling the SCREEN 12 statement.

Other versions:

Programs that do a similar thing:

  • NORMAL.BAS (its function is different, but it uses the "sticky" routines from this program as a novelty)
  • NORMAL.C (The DeSmet C for H-100 version of the NORMAL program)
10 'DLA3.BAS 
11 'COPYRIGHT (C)1991 STEVEN WHITNEY.
12 'Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY.
13 'Initially published by http://25yearsofprogramming.com.
14 'SIMULATES DIFFUSION LIMITED AGGREGATION.
15 'PARTICLE RANDOMLY WANDERS AROUND THE SCREEN.  WHEN IT COLLIDES WITH BOUNDARY, IT STICKS.  
16 'THIS VERSION STARTS AT CENTER OF A SMALL CIRCLE
17 'EXIT WITH CTRL-C OR CTRL-BREAK.
18 'SCREEN 12 : 'ENABLE FOR IBM BASICA 
20 'SET CENTERPOINT
30 RANDOMIZE
40 CLS
50 PSET (320, 112), 1
70 CIRCLE (320, 112), 30, 1
71 CIRCLE (320, 112), 31, 1
90 'KEEP THIS LINE, A BORDER TO PREVENT GOING OUT OF BOUNDS
100 LINE (0, 0)-(639, 0), 1: LINE -(639, 399), 1: LINE -(0, 399), 1: LINE -(0, 0), 1
110 'THIS REALLY SHOULD DRAW A CIRCLE AND START MOVING FROM A POINT ON IT
120 'X=INT(RND*640): Y=INT(RND*225)
121  X = 320: Y = 112
130 PSET (X, Y), 4
140 	'TEST TO SEE IF POINT IS NEXT TO ANOTHER POINT
150 	TST = POINT(X + 1, Y) OR POINT(X - 1, Y) OR POINT(X + 1, Y + 1) OR POINT(X, Y + 1) OR POINT(X - 1, Y + 1) OR POINT(X + 1, Y - 1) OR POINT(X, Y - 1) OR POINT(X - 1, Y - 1)
160 	IF TST THEN PSET (X, Y), 7: GOTO 110
170 	PSET (X, Y), 0
180 	M = INT(RND * 8)
190 	IF M = 0 THEN X = X + 1
200 	IF M = 1 THEN X = X - 1
210 	IF M = 2 THEN Y = Y + 1
220 	IF M = 3 THEN Y = Y - 1
230 	IF M = 4 THEN X = X + 1: Y = Y + 1
240 	IF M = 5 THEN X = X + 1: Y = Y - 1
250 	IF M = 6 THEN X = X - 1: Y = Y + 1
260 	IF M = 7 THEN X = X - 1: Y = Y - 1
270 	'NO NEED FOR OUT OF BOUNDS TEST - BORDER TAKES CARE OF IT
280 GOTO 130

 

 

Valid HTML 4.01 Transitional
Yahoo! Search
Search the web Search this site
Valid CSS