Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- patches-own
- [
- owner ;; turtle who claims patch for territory
- benefit ;; i.e., food
- avoiding ;; turtle who is avoiding this patch
- ]
- turtles-own
- [
- start-patch ;; my territory center
- destination ;; my next patch to claim
- territory ;; patches I own
- blacklist ;; my agentset of patches to avoid
- ]
- to pick-patch
- if patch-here = start-patch [ set destination highest-value ]
- if destination != nobody [ travel ]
- end
- to travel
- ;; there are a number of actions here, but the relevant one is:
- ;; check if owned, and avoid it:
- if patch-here != destination
- [ if owner != nobody ;; if it's owned...
- [ if owner != self ;; and not by me...
- [ avoid-obstacle
- move-to start-patch ]
- ]
- ]
- end
- to avoid-obstacle
- ask destination [ set avoiding myself ]
- set blacklist (patches with [avoiding = myself])
- end
- to-report highest-value ;; <--- source of error since using "blacklist"
- let available-destinations edge-patches with [blacklist != myself]
- report max-one-of available-destinations ([benefit-to-me / cost-to-me])
- end
- to-report benefit-to-me
- report mean [benefit] of patches in-radius 2
- end
- to-report cost-to-me
- report distance [start-patch] of myself
- end
- to-report edge-patches
- report (patch-set [neighbors4] of territory) with [owner = nobody]
- end
- to-report highest-value
- let available-destinations edge-patches with [avoiding != myself]
- report max-one-of available-destinations ([benefit-to-me / cost-to-me])
- end
- to avoid-obstacle
- ask destination
- [ let now-avoiding myself
- set avoiding (turtle-set avoiding now-avoiding) ]
- set blacklist (patch-set blacklist patches with [avoiding = myself])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement