Sorry if I annoy you, but my teacher says that this code[1] is not nice enough and I should work with agentsets instead of invidual values.
Code[1] (first code worked very nice)
let temp_ahead [(output-heat + 1)^ Freedom] of patch-ahead 1
let temp_right_ahead [(output-heat + 1)^ Freedom] of patch-right-and-ahead 45 1
let temp_right [(output-heat + 1)^ Freedom] of patch-right-and-ahead 90 1
let temp_right_back [(output-heat + 1)^ Freedom] of patch-right-and-ahead 135 1
let temp_back [(output-heat + 1)^ Freedom] of patch-right-and-ahead 180 1
let temp_left_back [(output-heat + 1)^ Freedom] of patch-left-and-ahead 135 1
let temp_left [(output-heat + 1)^ Freedom] of patch-left-and-ahead 90 1
let temp_left_ahead [(output-heat + 1)^ Freedom] of patch-left-and-ahead 45 1
set temp_ahead_kumulativ temp_ahead
set temp_right_ahead_kumulativ (temp_ahead_kumulativ + temp_right_ahead)
set temp_right_kumulativ (temp_right_ahead_kumulativ + temp_right)
set temp_right_back_kumulativ (temp_right_kumulativ + temp_right_back)
set temp_back_kumulativ (temp_right_back_kumulativ + temp_back)
set temp_left_back_kumulativ (temp_back_kumulativ + temp_left_back)
set temp_left_kumulativ (temp_left_back_kumulativ + temp_left)
set temp_left_ahead_kumulativ (temp_left_kumulativ + temp_left_ahead)
set propability_number (random-float (temp_left_ahead_kumulativ))
if propability_number < temp_ahead_kumulativ [right 0]
if propability_number < temp_right_ahead [right 45]
if propability_number < temp_right_kumulativ [right 90]
if propability_number < temp_right_back_kumulativ [right 135]
if propability_number < temp_back_kumulativ [right 180]
if propability_number < temp_left_back_kumulativ [left 135]
if propability_number < temp_left_kumulativ [left 90]
if propability_number < temp_left_ahead_kumulativ [left 45]
My Code[2] (is not working as Code[1], what is wrong?):
;;all temperatrue-values around the turtle saved in list
set temperature_values [(output-heat + 1) ^ Freedom] of neighbors
;;build cumulative value of temperatures and put each value in list
let tempsum 0
set tempsum_list []
foreach temperature_values
[set tempsum (tempsum + ? )
set tempsum_list lput tempsum tempsum_list
]
;;create a random number between 0 and the last tempsum-value
let probability_number random-float tempsum + 1
if probability_number < item 0 tempsum_list
[left 45]
if (probability_number < item 1 tempsum_list)
[left 90]
if (probability_number < item 2 tempsum_list)
[left 135]
if (probability_number < item 3 tempsum_list)
[right 180]
if (probability_number < item 4 tempsum_list)
[right 135]
if (probability_number < item 5 tempsum_list)
[right 90]
if (probability_number < item 6 tempsum_list)
[right 45]
if (probability_number < item 7 tempsum_list)
[right 0]
in Code[2] I tried to work with agentsets but the result doesn't look like the result in Code[1]. In Code[1] my turtles are creating nice huddles but in Code[2] they don't do that. I'm a little bit desperate... if anyone questions. the turtles should move in a higher probability to the patch with the higher value of "output-heat".