reset password
Author Message
tkitcha
Posts: 19
Posted 14:09 Apr 06, 2020 |

Overview:

Compute and, or randomly, return a number that represent a route based on whether or not the middle route is available and how many cars on each route.

In-dept:

From line 296 to 333, this procedure first check the availability of the middle route. If the middle route is on, then it will randomly selected a number from 0 to 2 if there is no cars, otherwise computation is required.

     Line 301-306
let top-score
      (count other commuters with [ route = 0 or route = 2 ] / count other commuters) * 1 + 1
      let bottom-score
      (count other commuters with [ route = 1 or route = 2 ] / count other commuters) * 1 + 1
      let middle-score
      (count other commuters with [ route = 2 ] / count other commuters) * 2

Each route will have a big score number if it has a lot of cars on it.

     Line 307-322
  ifelse top-score < bottom-score and top-score < middle-score
      [
        report 0
      ][
        ifelse bottom-score < middle-score and bottom-score < top-score
        [
          report 1
      ][
          ifelse top-score = bottom-score and middle-score = top-score
          [
            report random 3
          ][
            report 2
          ]
        ]
      ]

 The least score of all routes will be selected, but if somehow all routes are equal then the route will be randomly selected.

Another case is when the middle route is off, it will generally do the same thing as mentioned above, with the exclusion of the number for middle route.

Line 325-332
  [
    ifelse count other commuters = 0 [report random 2]
    [
      let top-score (count other commuters with [route = 0] / count other commuters) * 1 + 1
      let bottom-score (count other commuters with [route = 1] / count other commuters) * 1 + 1
      ifelse top-score < bottom-score [report 0][report 1]
    ]
  ]
Last edited by tkitcha at 14:12 Apr 06, 2020.
rabbott
Posts: 1649
Posted 18:52 Apr 06, 2020 |

Thanks, Tanya.