DECLARE SUB epsylon () DECLARE SUB pseurnd () DECLARE SUB random1 () DECLARE SUB xpos () DECLARE SUB ypos () DECLARE SUB vuldicht () DECLARE SUB Titel () COMMON SHARED nx%, ny%, dd, eps%, nt%, nn COMMON SHARED x%(), y%(), z%(), tel%() RANDOMIZE TIMER SCREEN 12 Titel Nog: CLS COLOR 11 PRINT " RANDOM fill of a space." COLOR 15 PRINT : PRINT : PRINT PRINT " -> 1 = random distribution" PRINT " -> 2 = homogeneous distribution" PRINT " -> 3 = about RANDIST" PRINT " -> ENTER = Stop" PRINT : PRINT : PRINT : COLOR 11 PLAY "l6b-" INPUT " -> Choice: ", kies$ IF kies$ = "" THEN PLAY "l12c+egb->d" END END IF IF kies$ <> "1" AND kies$ <> "2" AND kies$ <> "3" GOTO Nog SELECT CASE kies$ CASE "1" xpos ypos vuldicht nn = nx% * ny% * dd IF nn > 32000 THEN nn = 32000: dd = nn / (nx% * ny%) PRINT : COLOR 12 PRINT USING ">>> Overflow >>> taken maximum density ##.## "; dd PLAY "o4l12d": SLEEP 2: COLOR 15 CLS END IF REDIM z%(nx% * ny%) REDIM tel%(50) WINDOW (0, 0)-(nx% + 1, ny% * 1.05) CLS COLOR 12 LOCATE 1, 30 PRINT USING "dens.= ##.##, ##### = ### X ### positions"; dd; nx% * ny%; nx%; ny% COLOR 15 random1 GOTO Nog CASE "2" xpos ypos epsylon xx% = nx% / eps% + nx% MOD eps% '''max. along x, yy% = ny% / eps% + ny% MOD eps% ''' y, nt% = xx% * yy% '''expected max. occ. REDIM x%(nt%), y%(nt%) '''occupied posns. CLS WINDOW (1, 1)-(nx% + 1, 1 + ny% * 1.05) pseurnd GOTO Nog CASE "3" Titel GOTO Nog END SELECT END SUB epsylon eps: PLAY "o4l12d": LOCATE 24, 1 INPUT " -> Choose min. distance (default=3, 1 thru Nx or Ny) : ", eps% IF eps% = 0 THEN eps% = 3 IF eps% > nx% OR eps% > ny% OR eps% < 0 THEN LOCATE 20, 1 PRINT " " PLAY "o4l12d" GOTO eps END IF END SUB SUB pseurnd LOCATE 1, 1: COLOR 14: PRINT USING "Posns. : ##### /Dist. : ## /Max.:##### /Fill: #####"; nx% * ny%; eps%; nt%; i% FOR i% = 1 TO nt% worp2: x% = 1 + RND * (nx% - 1) y% = 1 + RND * (ny% - 1) IF i% = 1 THEN GOTO verder FOR j% = 1 TO i% - 1 IF ABS(x% - x%(j%)) < eps% AND ABS(y% - y%(j%)) < eps% THEN tel1% = tel1% + 1 IF tel1% > 100 GOTO opvullen LOCATE 1, 60: COLOR 3: PRINT USING "Worp:###"; tel1%: COLOR 15 GOTO worp2 END IF NEXT j% verder: tel% = tel% + 1 x%(i%) = x%: y%(i%) = y% tel1% = 0 teken: LOCATE 1, 47: COLOR 14: PRINT USING "#####"; i%: COLOR 15 LINE (x%, y%)-(x% + 1, y% + 1), , BF volg: IF INKEY$ <> "" THEN PRINT "STOP": END NEXT i% opvullen: '''look for holes, and fill tel1% = 0 i% = i% - 1 ii% = i% LOCATE 1, 60: COLOR 3: PRINT "Filling... ": COLOR 15 PLAY "o4l12d" FOR y% = 1 TO ny% FOR x% = 1 TO nx% FOR j% = 1 TO i% IF ABS(x% - x%(j%)) < eps% AND ABS(y% - y%(j%)) < eps% GOTO volg2 NEXT j% i% = i% + 1 IF i% > nt% THEN i% = nt%: GOTO statist2 x%(i%) = x%: y%(i%) = y% tel1% = tel1% + 1 teken2: PLAY "o4l12d" LOCATE 1, 47: COLOR 14: PRINT USING "#####"; i%: COLOR 15 LOCATE 1, 60: COLOR 3: PRINT USING "Filling : ####"; tel1%: COLOR 15 LINE (x%, y%)-(x% + 1, y% + 1), 3, BF volg2: NEXT x% NEXT y% statist2: LOCATE 1, 60: COLOR 11: PRINT "-> Key... " PLAY "o2l6a>l12fedc+" SLEEP: a$ = INKEY$ CLS PRINT USING "Fill stats. about the ##### occupations:"; i% PRINT : PRINT : COLOR 15 PRINT " number of positions : "; nx% * ny% PRINT " required distance : "; eps% PRINT " max. occupancy : "; nt% PRINT " occupancy achieved by tossing : "; ii% PRINT " by filling in : "; i% - ii% PRINT " total occupancy achieved : "; i% PRINT " equivalent distance : "; : PRINT USING "###.#"; SQR(nx% * ny% / ii%) PRINT : PRINT : PRINT COLOR 11: PRINT " -> Key... " COLOR 15 PLAY "l6d Key... ": COLOR 15 PLAY "o2l6a>l12fedc+" SLEEP: a$ = INKEY$ CLS : COLOR 11 PRINT USING "Fill stats. about the ##### positions (##### tosses)"; nx% * ny%; nx% * ny% * dd PRINT : PRINT : COLOR 15 FOR i% = 0 TO 20 PRINT USING "##.# % ##### times selected"; tel%(i%) / (.01 * nx% * ny%); i% NEXT i% PRINT : PRINT : PRINT COLOR 11: PRINT " -> Key... " COLOR 15 PLAY "l6d Key... " COLOR 15 PRINT : PRINT : PRINT PRINT "Is a random distribution of matter in space homogeneous?" PRINT "Is a homogeneous distribution random?" PRINT PRINT "In this program the two notions are being displayed, both applying" PRINT "for the label 'random'." PRINT "Space in our case consists of a field of (x,y) positions," PRINT "number to be chosen. Each toss (x,y) is itself fully random." PRINT PRINT "Our first kind of distribution accepts each toss. As a consquence," PRINT "positions may be occupied more than once (something matter couldn't do)." PRINT "Other positions may stay vacant. The end result depends largely on " PRINT "the ratio between the numbers of tosses and of available positions." PRINT PRINT "The second distribution accepts only tosses that maintain a given" PRINT "minimal distance to positions already occupied. No double occupation" PRINT "in this case: it's like a swarm of bats keeping distance amongst" PRINT "each other." PRINT PRINT "What kind of distribution you think corresponds best to matter in space?" PRINT "So what about the search for structure in the universe, what with clusters," PRINT "superclusters and bubbles: shouldn't we relativize a bit there?" LOCATE 28, 1: COLOR 10: PRINT " Credits: Guido Wuyts 1996" PLAY "o2l6a>l12fedc+" COLOR 11 SLEEP: a$ = INKEY$ CLS COLOR 11 PRINT " RANDOM fill of a space. (2/3) -> Key... " COLOR 15: PRINT : PRINT : PRINT PRINT " 1. Random distribution." PRINT PRINT "Consider a space of N = Nx.Ny positions, arranged along" PRINT "x- and y-directions of Nx and Ny places respectively." PRINT "Fill positions in this space through randomly tossing (x,y)." PRINT "Each toss at equal chance." PRINT PRINT "Do N times D tosses: D = fill density (ratio tosses/positions)." PRINT "Check following questions:" PRINT PRINT " -> % of positions selected 1, 2, 3... times?" PRINT " -> % of positions remaining empty?" PRINT " -> starting from which density D fill almost complete?" PRINT PRINT " Notice also, for smaller densities, pseudostructures in the shape of" PRINT " clusters, for larger ones in the shape of holes (bubbles): random" PRINT " distribution is Not homogeneous! By the way, this is a fractal " PRINT " property that holds for all scales of material fill: " PRINT " nebulae, galaxies, clusters and beyond..." LOCATE 28, 1: COLOR 10: PRINT " Credits: Guido Wuyts 1996" PLAY "l6d" SLEEP: a$ = INKEY$ CLS COLOR 11 PRINT " RANDOM fill of a space. (3/3) -> Key... " COLOR 15: PRINT : PRINT : PRINT PRINT " 2. Homogeneous distribution." PRINT PRINT "The same space with Nx.Ny = N positions. All tosses (x,y) equally" PRINT "random. This time, we fill only (x,y) if distance to all previous" PRINT "occupations exceeds a chosen minimum." PRINT "Otherwise the toss is ignored and a next toss made." PRINT PRINT "Once the number of successive 'vain' tosses exceeds a hundred," PRINT "density of occupation has reached a point where chances at a new" PRINT "toss that proves 'right' decrease rapidly. For practical purposes we" PRINT "then change strategy. We scan sequentially all positions and check" PRINT "them for 'fillability'. Thus we reach the maximum fill that is -yet-" PRINT "possible after the random toss stage." PRINT PRINT "Chances are it isn't the maximum possible fill, given the minimal" PRINT "distance: that would be a regular crystal grid fill. Our " PRINT "homogeneous distribution then holds an element of randomness." PRINT "Some statistics compare the distances required and obtained, " PRINT "and corresponding numbers of occupation." LOCATE 28, 1: COLOR 10: PRINT " Credits: Guido Wuyts 1996" PLAY " Choose fill density (default=.25, 0+ thru 10) : ", dd IF dd = 0 THEN dd = .25 IF dd < 0 OR dd > 10 THEN LOCATE 24, 1 PRINT " " PLAY "o4l12d" GOTO vul END IF END SUB SUB xpos xpos: PLAY "o4l12d": LOCATE 20, 1 INPUT " -> Choose nr. of x-positions (default=65, 10 thru 200) : ", nx% IF nx% = 0 THEN nx% = 65 IF nx% < 10 OR nx% > 200 THEN LOCATE 20, 1 PRINT " " PLAY "o4l12d" GOTO xpos END IF END SUB SUB ypos ypos: PLAY "o4l12d": LOCATE 22, 1 INPUT " -> Choose nr. of y-positions (default=40, 5 thru 150) : ", ny% IF ny% = 0 THEN ny% = 40 IF ny% < 5 OR ny% > 150 THEN LOCATE 22, 1 PRINT " " PLAY "o4l12d" GOTO ypos END IF END SUB