Pursuit of Happiness
Model was written in NetLogo 5.0.3
•
Viewed 282 times
•
Downloaded 25 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] turtles-own [happy? antihappy? antiunhappy? happiness] Globals [ percent-sad serial-port] to gogosetup ifelse length (gogo:ports) > 0 [ set serial-port user-one-of "Select a port:" gogo:ports ] [ user-message "There is a problem with the connection. Check if the board is on, and if the cable is connected. Otherwise, try to quit NetLogo, power cycle the GoGo Board, and open NetLogo again. For more information on how to fix connection issues, refer to the NetLogo documentation or the info tab of this model" stop ] gogo:open serial-port repeat 5 [ if not gogo:ping [ user-message "There is a problem with the connection. Check if the board is on, and if the cable is connected. Otherwise, try to quit NetLogo, power cycle the GoGo Board, and open NetLogo again. For more information on how to fix connection issues, refer to the NetLogo documentation or the info tab of this model"] ] gogo:talk-to-output-ports [ "a" "b" "c" "d"] end to setup clear-all set-default-shape turtles "person" ask n-of number patches [ sprout 1 [set color blue]] ask n-of (number / 2) turtles [set color green] light-initial setup-happiness setup-unhappiness setup-anti reset-ticks end to light-initial ifelse gogo:sensor 1 > 500 [ask turtles [set happiness 20]] [ask turtles [set happiness 40]] end to check-light ifelse gogo:sensor 1 < 500 [ask turtles [set happiness happiness + random 10] ask patches [set pcolor 89]] [ask turtles [set happiness happiness - random 10] ask patches [set pcolor 0]] end to setup-happiness ask turtles with [color = green] [set happy? true] end to setup-unhappiness ask turtles with [color = blue] [set happy? false] end to setup-anti ask turtles [set antihappy? false] ask turtles [set antiunhappy? false] end to go move pass-on-happiness keep-on-happiness pass-on-unhappiness if gogo:sensor 1 >= 800 [fast-happy-fade check-light update-globals] if (gogo:sensor 1 > 500) and (gogo:sensor 1 < 800) [normal-happy-fade check-light update-globals] if gogo:sensor 1 <= 500 [slow-happy-fade check-light update-globals] tick ;update-globals end to move ifelse gogo:sensor 1 >= 600 [ask turtles [rt random 360 fd 0.5]] [ask turtles [rt random 360 fd 1]] end to pass-on-happiness ask turtles with [happy?] [ask other turtles-here with [not happy?] [happy-gain]] end to keep-on-happiness ask turtles with [happy?] [ask other turtles-here with [happy?] [keep-happy]] end to pass-on-unhappiness ask turtles with [not happy?] [ask other turtles-here with [not happy?] [keep-sad]] end to set-mood ifelse happiness > 20 [set happy? true set color green] [set happy? false set color blue] end to keep-happy happy-gain set antiunhappy? true end to keep-sad set antihappy? true end to slow-happy-fade ask turtles with [happy?] [if antiunhappy? [if happiness >= 20 [set happiness happiness - 1] ]] ask turtles [set-mood] end to normal-happy-fade ask turtles with [happy?] [if not antihappy? [if not antiunhappy? [if happiness >= 20 [set happiness happiness - 2] ]]] ask turtles [set-mood] end to fast-happy-fade ask turtles with [happy?] [if antihappy? [if happiness >= 20 [set happiness happiness - 3] ]] ask turtles [set-mood] end to happy-gain set happiness happiness + 1 end to update-globals set percent-sad (count turtles with [not happy?]) / (count turtles) * 100 end ;IF happiness 40 ;if happy. >40 ;set happy happy -1 ;if happy < 20 ;sad ;end ;if random 100< 20 [get sad]
There is only one version of this model, created almost 12 years ago by Jacob Wilkes.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Pursuit of Happiness.png | preview | Preview for 'Pursuit of Happiness' | over 11 years ago, by Jacob Wilkes | Download |
This model does not have any ancestors.
This model does not have any descendants.