to haus_vom_nikolaus ; Das Haus vom Nikolaus: ; mit den 45 Möglichkeiten von Juergen Koellers Homepage ; Start von Punkt 1 mit Ende auf Punkt 2 local [r k h_anzahl a b punkte singleshot] singleshot=Name? "framenr clearScreen hideTurtle setpensize [5 5] setLabelSize [40 40] k=Reihenfolge h_anzahl=45 ; Anzahl Häuser, max.45 a=300 b=200 ;Seitenlängen ; Definition der Punkte 1 bis 5 punkte = (Array (List List 0 0 List a 0 List a b List 0 b List a/2 b*3/2)) - List a/2 b/2 if singleshot [ clearScreen r=framenr type word r ": Haus k.r stop ] OnChar [OnChar [] throw "stopping] ; Häuser zeichnen catch "stopping [ repeat h_anzahl [ clearScreen r=repcount type word r ": Haus k.r ] ] OnChar [] pr [\;Ok] end to Haus h local [r tt wzeit1 wzeit2 nr] tt=[[] Das ist das Haus vom Ni- ko- laus.] wzeit1=200 wzeit2=1000 ; Wartezeiten nach jeder Verbindung, nach jedem Haus print h PenUp setXY -a b right 90 label repcount left 90 repeat 7 [ r=repcount PenUp setPos punkte.(h.r) right 90 label h.r left 90 ] setPos punkte.(h.1) PenDown repeat 9 [ nr=h.repcount pd slowSetPos punkte.nr HSB 360*(repcount-1)/9 1 .8 pu setXY -a b-(repcount-1)*40 ang=Heading setHeading 90 label tt.repcount setHeading ang setPos punkte.nr updateGraph if not singleshot [waitMS :wzeit1] ] if not singleshot [waitms :wzeit2] end to slowSetPos p c local [o oc] o=Pos oc=reRGB PenColor c=reRGB c setHeading towards p repeat 10 [ setPenColor (list oc.1+(c.1-oc.1)*repcount/10 oc.2+(c.2-oc.2)*repcount/10 oc.3+(c.3-oc.3)*repcount/10) setPos o+(p-o)*repcount/10 if not singleshot [ waitMS 20 updateGraph redraw ] ] end to ok? n w=weg ok=true while [not empty? butFirst w] [ if (p==(first w) and2 n==w.2) or2 (n==(first w) and2 p==w.2) [ ok=false break ] w=butFirst w ] output ok end to traverse weg p ;show weg local [nl n] nl=nachbarn.p foreach nl [ n=? if ok? n [ traverse se weg n n ] ] ;pr weg if (count weg)==9 [ ;pr weg queue "wege weg ] end to Reihenfolge nachbarn=Array Int (List [2 3 4][1 3 4][1 2 4 5][1 2 3 5][3 4]) wege=[] traverse Int [1] Int 1 output wege end