// Theme: outside // // One Keyword: experience number mod val1 val2 { value (val1 - ((val1 / val2) * val2)) } set SEED 123 set largePrime 2333 number random maxval { set SEED value (SEED * maxval / largePrime) } number sqr val { value ((val/10)*(val/10)) } number float2dbn val { value (val / 100) } number dbn2float val { value (val * 100) } number sqrt_guess val guess { value ((val - ) * 50 / guess + guess) } number sqrt val { set current_guess val set close_enough repeat a 1 15 { set next_guess smaller? (current_guess-next_guess) close_enough { notsmaller? (current_guess-next_guess) (-close_enough) { set a 16 } } set current_guess next_guess } value current_guess } number getMyX y { set x smaller? y 7 { set x } notsmaller? y 7 { smaller? y 30 { set x ( - (3 * ->)> / 2)) } notsmaller? y 30 { smaller? y 47 { } notsmaller? y 47 { smaller? y 60 { set x ( - (3 * ->)>)) } notsmaller? y 60 { smaller? y 100 { set x ( + ->)>) } } } } } value } command colorMe { repeat y 0 100 { line 0 y y } } set size 4 set totalInfo 10 command resetInfoNum a { set y set myx set x ( + myx) set vx 1 set vy (*2-1) set x set y set vx set vy } command resetInfo { repeat a 0 totalInfo { resetInfoNum a } } command drawInfo color goalcolor goal { repeat a 0 totalInfo { set x set y smaller? a 3 { same? goal 0 { set [x y] color } notsame? goal 0 { pen goalcolor repeat ty -3 3 { line (x-3) (y+ty) (x+3) (y+ty) } pen 100 repeat ty -1 1 { line (x-1) (y+ty) (x+1) (y+ty) } pen goalcolor line x y (x-5) (y-2) line x y (x-5) (y+2) } } notsmaller? a 3 { set [x y] color } } } command moveInfo goal { repeat a 0 totalInfo { set x set y set ox x set oy y set vx set vy set x (x+vx) set y (y+vy) set MyX set special 0 set dontTouch 0 notsame? goal 0 { smaller? a 3 { set special 1 } } same? special 0 { smaller? x MyX { set x (MyX+2) set vx 1 } notsmaller? x 88 { set x 88 set vx -1 } smaller? y 0 { set y 0 set vy 1 } notsmaller? y 100 { set y 100 set vy -1 } } notsame? special 0 { smaller? x MyX { resetInfoNum a set dontTouch 1 } notsmaller? x MyX { smaller? y 80 { set vy (vy+1) smaller? 6 vy { set vy 6 } } notsmaller? y 80 { set vy (vy-1) smaller? vy -6 { set vy -6 } } set vx (vx-1) smaller? vx -6 { set vx -6 } } } same? dontTouch 0 { set x set y set vx set vy } } } command runProject { resetInfo paper 100 pen 0 colorMe set goal 0 repeat t 0 100 { set oldgoal goal refresh drawInfo 100 85 goal norefresh smaller? t 10 { set goal 0 } notsmaller? t 10 { set goal 1 } moveInfo goal drawInfo 25 50 oldgoal } } runProject