Phototropism
No preview image
Model was written in NetLogo 5.0RC7
•
Viewed 329 times
•
Downloaded 27 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
extensions [gogo] breed [suns sun] breed [cells cell] breed [rays ray] breed [growturtles growturtle] cells-own [auxins] rays-own [power] ;growturtles-own [dx dy] globals[ theGrowTurtle ;; a turtle that helps me calculate the direction that the plant grows in theSun ;; the sun usb-port initLeftLevel ;initial level of light on the left initRightLevel ;for right lastLeftLevel lastRightLevel ] to initiateGogo ;set usb-port user-one-of "Select a port:" gogo:ports set usb-port "/dev/tty.usbmodem411" gogo:open usb-port repeat 5 [ if not gogo:ping [ user-message "The GoGo Board is not responding." ] ] gogo:talk-to-output-ports [ "a" "b" "c" "d" ] end to-report calibrateSensors ;measures the average light level in the room let calbLeftList [] let calbRightList [] repeat 3 [ set calbLeftList (lput (gogo:sensor 1) calbLeftList) set calbRightList (lput (gogo:sensor 2) calbRightList) wait 0.1 ] let leftLevel mean calbLeftList let rightLevel mean calbRightList report list leftLevel rightLevel end to setup ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) initiateGogo set lastLeftLevel first calibrateSensors set lastRightLevel last calibrateSensors __clear-all-and-reset-ticks reset-ticks create-growturtles 1 [hide-turtle set size 5 set shape "default" set heading 0] set theGrowTurtle one-of growturtles set-default-shape turtles "circle" ;; create plant create-cells 25 [ set heading 0 set pen-size 10 set xcor (5 - random 10) set ycor -16 set color green set auxins 200 pen-down ] ; ask cells [create-links-with other cells] ; layout-spring cells links 5 2 1 ;; create sun create-suns 1 [ set size 5 set color yellow ] ;; set theSun set theSun one-of suns ; @todo remove this when the sun moves dynamically ask theSun [set ycor 14] positionSun end to go tick if ticks mod 5 = 0 [positionSun] ;; @todo implement positionSun to dynamically change position of sun relative to light sensor input ; positionSun ask theSun [ shootRays ] ask rays [ moveRays ] ask rays [ checkRayCollision ] if ticks > 35[ ask cells with [auxins > 0] [ move ] ] ;; end if all cells out of auxins if sum [auxins] of cells < 0 [stop] end to positionSun ; @todo change to reflect relative light let currentLeftLevel first calibrateSensors ;gets the current light value from sensors let currentRightLevel last calibrateSensors let leftLevelDif lastLeftLevel - currentLeftLevel let rightLevelDif lastRightLevel - currentRightLevel set lastLeftLevel currentLeftLevel set lastRightLevel currentRightLevel let maxPoint 600 ;this is to filter abnormal sensor values (sometimes gives values up to 50000) if (currentLeftLevel > 0) and (currentRightLevel > 0) and (currentLeftLevel < maxPoint) and (currentRightLevel < maxPoint) [ let totalLevel (currentLeftLevel + currentRightLevel) let sensorRatio (currentLeftLevel / currentRightLevel) show sensorRatio if sensorRatio > 2 [set sensorRatio 2] ask theSun [set xcor (14 - (sensorRatio * 14))] ] end to calculateDirection setxy mean [xcor] of cells mean [ycor] of cells let deltaX 0 let deltaY 0 ask cells [ set deltaX [xcor] of myself - (xcor + (sin heading) * auxins / 200) set deltaY [ycor] of myself - (ycor + (cos heading) * auxins / 200) ] ; show deltaY if abs deltaY > .01 [show deltaY set heading atan deltaX deltaY] end to shootRays hatch-rays 15 [set heading 90 + random 180 set shape "default" set size .5 ; @todo change to reflect sum of light from sensors set power 20] end to moveRays fd 1 if xcor > 15 or xcor < -15 or ycor < -15 [die] end to checkRayCollision if any? cells-here [ set size 10 ;; var for calling cell let aCell one-of cells-here ;; subtract the power of the sunray from my auxins count ask aCell[ set auxins auxins - [power] of myself set color color - 10 ] die ] end to move set heading [heading] of theGrowTurtle fd auxins / 300 set auxins auxins - 2 end
There is only one version of this model, created almost 13 years ago by Arthur Hjorth.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.