Model on NetLogo: Color Fractions

5 Views Asked by At

I have the following code in NetLogo:

patches-own [ column-number ]

to setup clear-all ask patches [ set plabel-color black set column-number pxcor + max-pxcor ] go reset-ticks end

to go let n numerator ;; go through every patch one at a time in order, ;; (left to right, top to bottom) foreach sort patches [ p -> ask p [ ifelse column-number >= width [ ;; patches outside the given width are black set plabel "" set pcolor black ] [ ;; other patches get a color and label ;; perform the division set plabel floor (n / denominator) ifelse plabel = 0 [ set pcolor gray + 1.5 ] ;; 0 is gray [ set pcolor plabel * 10 + 6 ] ;; other digits get colors ;; compute the new numerator set n 10 * remainder n denominator ] ] ] ;; put a decimal point after the number in the ;; upper left corner patch ask patch min-pxcor max-pycor [ set plabel word plabel "." ] display end

And I want to modify this code. The aim is to see $\pi$ and square roots in the programme.

Can anyone give an idea to modify this programme?

I have done some modifications like change the lightness/darkness of the boxes and change the colour of the boxes depending of the number is odd or pair.

Thanks so much.