Общие вопросы, касающиеся Netlogo - PullRequest
2 голосов
/ 25 мая 2019

Я очень новичок в Netlogo и пытаюсь выучить основы. Поэтому я пытаюсь расширить пример кода, предоставленного Netlogo. Я пытаюсь сделать уровень загрязнения зависимым от количества людей из примера загрязнения городских территорий.

Есть ли способ ввести усиленное обучение (Q-learning) для улучшения симуляции?

Sincerly, Victor

Нужно ли создавать новую функцию, которая обновляет загрязнение при увеличении численности населения?

Below is the example code:

breed [ people person ]
breed [ trees tree ]

turtles-own [ health ]

patches-own [
  pollution
  is-power-plant?
]

to setup
  clear-all

  set-default-shape people "person"
  set-default-shape trees "tree"

  ask patches [
    set pollution 0
    set is-power-plant? false
  ]

  create-power-plants

  ask patches [ pollute ]

  create-people initial-population [
    set color black
    setxy random-pxcor random-pycor
    set health 5
  ]

  reset-ticks
end

to go

  if not any? people [ stop ]

  ask people [
    wander
    reproduce
    maybe-plant
    eat-pollution
    maybe-die
  ]

  diffuse pollution 0.8

  ask patches [ pollute ]

  ask trees [
    cleanup
    maybe-die
  ]

  tick
end

to create-power-plants
  ask n-of power-plants patches [
    set is-power-plant? true
  ]
end

to pollute  ;; patch procedure
  if is-power-plant? [
    set pcolor red
    set pollution polluting-rate
  ]
  set pcolor scale-color red (pollution - .1) 5 0
end

to cleanup  ;; tree procedure
  set pcolor green + 3
  set pollution max (list 0 (pollution - 1))
  ask neighbors [
    set pollution max (list 0 (pollution - .5))
  ]
  set health health - 0.1
end

to wander  ;; person procedure
  rt random-float 50
  lt random-float 50
  fd 1
  set health health - 0.1
end

to reproduce  ;; person procedure
  if health > 4 and random-float 1 < birth-rate [
    hatch-people 1 [
      set health 5
    ]
  ]
end

to maybe-plant  ;; person procedure
  if random-float 1 < planting-rate [
    hatch-trees 1 [
      set health 5
      set color green
    ]
  ]
end

to eat-pollution  ;; person procedure
  if pollution > 0.5 [
    set health (health - (pollution / 10))
  ]
end

to maybe-die  ;; die if you run out of health
  if health <= 0 [ die ]
end


; Copyright 2007 Uri Wilensky.
; See Info tab for full copyright and license.
...