;Hello George mills
;This message I posted 3 days ago.My server was out of order!.I am
;not sure you recieved it.
;Here is the general random points fractal generating code written
;in MSWLogo for number of sides 3,4,5,6,8
;The results Are Very Similar to those I Have sent to KEITH ENEVOLDSEN
;some 6 monthes ago with diterminstic code.
;Best Regards
;Mhelhefny
;----------------------------------------------------
to get.point :lev :aa
; Using a loop made it easier to add the "hit" flag
; I could of just put a "Global" flag in plot.midpoint
; But I try to avoid globals when possible.
; It certainly could of still been done recursively.
localmake "Hit "False
ifelse :aa =1[make "w [[0 0][600 0][300 270]]][
ifelse :aa =2[make "w [[0 0][400 0][400 400][0 400]]][
ifelse :aa =3[make "w [[0 0][400 0][520 380][200 616][-124 380]]][
ifelse :aa =4[make "w [[0 0][400 0][600 246][400 492][0 492][-200 246]]][
if :aa =5[make "w [[0 0][300 0][512 212][512 512][300 725]~
[0 725][-212 512][-212 212]]]]]]]
if :aa =5 [make "aa :aa+1]
repeat :lev ~
[
make "T.pt item 1 + random (:aa+2) :w
if plot.midpoint :z :T.pt [make "Hit "True]
make "z pos
]
output :Hit
end
to go
cs ht
setpensize [2 2]
make "z list random 600 random 600
pu
make "aa SelectBox [chose numer of sides][[3 sierpins tr] [4 carpet] 5 6 8]
localmake "TotalPoints 0
localmake "MissInARow First QuestionBox [] [Enter Number of Hits in a
Row to stop at (e.g. 15)]
; Keep running until we get MissInARow
do.while ~
[
Print :TotalPoints
make "TotalPoints :TotalPoints + :MissInARow
] [get.point :MissInARow :aa]
ifelse :aa>4 [make "aa :aa+1][]
pu rt 90 setxy -120 -120 pd label (se "fractal_sides "= :aa+2)
end
to plot.midpoint :Pt.1 :Pt.2
; Using SetXY is slight more efficient
setxy -100+ ((first :Pt.1) + (first :Pt.2))*.3 ~
-50+ (( last :Pt.1) + ( last :Pt.2))*.3
; If this XY has not been hit before we are still making progress
if not pixel = [0 0 0] ~
[
setpixel [0 0 0]
output "True
]
; We already hit that one
output "False
end
;--------------------------------------------------------------
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home