Netlogo giving attribute value of agent based on value of patch and slider parameter (2) -
so, previous question want make buycapability attribute of agents. attribute consists of 3 categories high middle , low. there 3 threshold values of buycapability >= 50 (low), 50>m<=100 (middle) , >100 (high) determined 2 sliders. besides, agent stays on patch has land-price attribute. so, buycapability determined land-price , threshold values. example, if land-price of agent's patch greater 100(slider buycapability_high value) agent's buycapability high , on in procedure to-set-income-resident. below code code use far, create or make buycapability categorization. unfortunately, result of code buycapability attribute af agents low, there no other that. though land-price greater 100 should high it's not. please me find might wrong code or other possibility.
patches-own [value empty] turtles-own [income myhouses ] setup ca ;;check inputs let total-prob prob-rendah + prob-sedang + prob-tinggi if (total-prob != 100 ) [ print (word "totalprob must sum 100, instead sum " total-prob) stop ] create-turtles 100 [setxy random-pxcor random-pycor set shape "default" set size 1 ;set-income set-income2] ask patches [set value random-normal 10 6 set pcolor brown + value set empty true] end set-income2 if[value] of patch-here > buycapability_middle , [value] of patch-here <= buycapability_high [set income "middle"] if[value] of patch-here > buycapability_high [set income "high"] if[value] of patch-here <= buycapability_middle [ set income "low"] end go let target [] ask turtles [income = "low"] [ let potential-target1 patches [value < buycapability_middle , any? turtles-here = false] set target min-one-of potential-target1 [value] pen-down move-to target ask patch-here [set empty false]] ask turtles [income = "middle"] [ let potential-target2 patches [value < buycapability_high , value > buycapability_middle , any? turtles-here = false] set target min-one-of potential-target2 [value] pen-down move-to target ask patch-here [set empty false]] ask turtles [income = "high"] [ let potential-target3 patches [value > buycapability_high , any? turtles-here = false] set target min-one-of potential-target3 [value] pen-down move-to target ask patch-here [set empty false]] end
is actual code?
i think because put patch's value initialization after set-income
. way, every time setup, patches's value function set-income
0 since haven't set value yet.
try putting set-income
at end of code
to setup .... .... ask patches [ set value random-normal 6 10 ... ... ] set-income2 end
hope helps.
Comments
Post a Comment