Libraries‎ > ‎Somie‎ > ‎

Make fields

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Make fields

(Make fields)

End description

Make fields

Begin NetLogo code:

;; create square fields with values from the chooserask patch-at round mouse-xcor round mouse-ycor [   let x mouse-xcor   let y mouse-ycor  let b mouse-xcor + ( round sqrt ( the-chooser-2 * 1000 ) )   let aa count patches with [ pxcor >= x and pxcor <= b and pycor <= y and pycor >= min-pycor and use-of-patch = "farmland" and crop-of-patch = 0 ]  ifelse aa > ( the-chooser-3 * 1000 )   [    ask max-n-of ( the-chooser-3 * 1000 ) patches with [ pxcor >= x and pxcor <= b and pycor <= y and pycor >= min-pycor and use-of-patch = "farmland" and crop-of-patch = 0 ] [ pycor ] [     set pcolor pcolor + 1     set crop-of-patch the-chooser-1 ];; construct a task to start digging this field a month before planting date    let c1 the-chooser-1 ;; crop    let c2 the-chooser-2 ;; planting month    ;; turn the month chosen into chooser-3 into a number, and subtract 1 to start digging 1 month before planting date chosen    let dd [ "Jan" "feb" "march" "Apr" "Mai" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" ]    let ccc 0     let counter 0 foreach dd [ set counter counter + 1 if ? = c2 [ set ccc counter - 1 ] ]    let a [ 1 1 1 1 1 1 1  ]    set a replace-item 0 a "dig"    set a replace-item 1 a c1    set a replace-item 2 a "farmland"    set a replace-item 3 a ccc    set a replace-item 4 a 16    set a replace-item 5 a 70    set a replace-item 6 a [ "male" "female" ]    set the-activity-roster fput a the-activity-roster  ]  [     ask max-n-of aa patches with [ pxcor >= x and pxcor <= b and pycor <= y and pycor >= min-pycor and use-of-patch = "farmland" and crop-of-patch = 0 ] [ pycor ] [       set pcolor green       set crop-of-patch the-chooser-1 ];; construct a task to start digging this field a month before planting date    let c1 the-chooser-1    let c2 the-chooser-2    ;; turn the month chosen into chooser-3 into a number, and subtract 1 to start digging 1 month before planting date chosen    let dd [ "Jan" "Feb" "Mar" "Apr" "Mai" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" ]    let ccc 0     let counter 0 foreach dd [ set counter counter + 1 if ? = c2 [ set ccc counter - 1 ] ]    let a [ 1 1 1 1 1 1 1  ]    set a replace-item 0 a "dig"    set a replace-item 1 a c1    set a replace-item 2 a "farmland"    set a replace-item 3 a ccc    set a replace-item 4 a 16    set a replace-item 5 a 70    set a replace-item 6 a [ "male" "female" ]    set the-activity-roster fput a the-activity-roster      ]   ]

End NetLogo code

Variants

How this works

Related micro-behaviours

History

BehaviourComposer: ignore everything after this.