From 44f204b1217219018d880ac512aa074131c38e3e Mon Sep 17 00:00:00 2001 From: Bryan Head Date: Tue, 5 May 2015 23:19:29 -0500 Subject: [PATCH 1/4] Allow globals as args. Fixes #52 Remove agent vars from being selected when agent is observer --- LevelSpaceXWGUI.nlogo | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/LevelSpaceXWGUI.nlogo b/LevelSpaceXWGUI.nlogo index 03a083d..440c3eb 100644 --- a/LevelSpaceXWGUI.nlogo +++ b/LevelSpaceXWGUI.nlogo @@ -787,7 +787,7 @@ to add-model-globals [the-model] ;; not sure if these should be reporters (which they technically are) or 'globals' since we probably don't want to SET ;; reporters, but we may want to set globals? ;; setting to value now, might not be right though...... - let the-type "value" + let the-type "reporter" let the-entity new-entity global-name the-model global-name args the-type "OTLP" table:put the-entity "builtin" true add-entity the-entity @@ -927,7 +927,12 @@ to-report get-from-model-all-types [model-id a-type] end to-report get-eligible-arguments [an-entity] - report filter [table:get last ? "type" = "reporter" and table:get last ? "args" = [] ] table:to-list tasks + let observer? table:get an-entity "type" = "observer" + report filter [ + table:get last ? "type" = "reporter" and + table:get last ? "args" = [] and + not (observer? and not member? "O" table:get last ? "contexts") + ] table:to-list tasks end to-report agent-names From 4d23c5964fb351f17fecce6ef26c25a90ca67c8c Mon Sep 17 00:00:00 2001 From: Bryan Head Date: Tue, 5 May 2015 23:25:58 -0500 Subject: [PATCH 2/4] Only allow agent reporter args if from same model --- LevelSpaceXWGUI.nlogo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LevelSpaceXWGUI.nlogo b/LevelSpaceXWGUI.nlogo index 440c3eb..6cc9067 100644 --- a/LevelSpaceXWGUI.nlogo +++ b/LevelSpaceXWGUI.nlogo @@ -928,10 +928,12 @@ end to-report get-eligible-arguments [an-entity] let observer? table:get an-entity "type" = "observer" + let model table:get an-entity "model" report filter [ table:get last ? "type" = "reporter" and table:get last ? "args" = [] and - not (observer? and not member? "O" table:get last ? "contexts") + (not observer? or member? "O" table:get last ? "contexts") and + (model = table:get last ? "model" or member? "O" table:get last ? "contexts") ] table:to-list tasks end From 1a411456a56ad7c0c66ecdecbf43aabd7b4da913 Mon Sep 17 00:00:00 2001 From: Bryan Head Date: Tue, 5 May 2015 23:51:18 -0500 Subject: [PATCH 3/4] Don't show arguments with visible = false --- LevelSpaceXWGUI.nlogo | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/LevelSpaceXWGUI.nlogo b/LevelSpaceXWGUI.nlogo index 6cc9067..e97cc35 100644 --- a/LevelSpaceXWGUI.nlogo +++ b/LevelSpaceXWGUI.nlogo @@ -516,8 +516,11 @@ to add-entity-to-col [an-entity ] xw:set-args string:from-list get-args the-entity " " xw:set-y margin + sum map [[xw:height] xw:of ?] left-column set left-column lput the-name left-column -; xw:set-save-command (word "save-entity-from-widget \"" the-name "\" " entity-id " show-it") -; xw:set-delete-command (word "delete-entity " entity-id) + xw:on-visible?-change [ + table:put the-entity "visible" ? + draw-center + ] + xw:set-visible? table:get the-entity "visible" ] ] [ @@ -933,7 +936,8 @@ to-report get-eligible-arguments [an-entity] table:get last ? "type" = "reporter" and table:get last ? "args" = [] and (not observer? or member? "O" table:get last ? "contexts") and - (model = table:get last ? "model" or member? "O" table:get last ? "contexts") + (model = table:get last ? "model" or member? "O" table:get last ? "contexts") and + table:get last ? "visible" ] table:to-list tasks end From 01ea3471312374f34fc4979348151cd4a039c46f Mon Sep 17 00:00:00 2001 From: Bryan Head Date: Tue, 5 May 2015 23:55:31 -0500 Subject: [PATCH 4/4] Don't show commands and agents with visible = false --- LevelSpaceXWGUI.nlogo | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/LevelSpaceXWGUI.nlogo b/LevelSpaceXWGUI.nlogo index e97cc35..8ad7b1f 100644 --- a/LevelSpaceXWGUI.nlogo +++ b/LevelSpaceXWGUI.nlogo @@ -190,7 +190,7 @@ to draw-center xw:set-y margin + sum map [[xw:height] xw:of ?] center-column xw:set-width center-column-width xw:set-x margin * 2 + left-column-width - xw:set-available-agent-reporters map [(word table:get last ? "model" ":" name-of last ?)] all-agent-entities + xw:set-available-agent-reporters map [(word table:get last ? "model" ":" name-of last ?)] filter [table:get last ? "visible"] all-agent-entities xw:set-available-procedures [] xw:set-selected-agent-reporter-index 0 xw:on-selected-agent-reporter-change [ @@ -702,27 +702,30 @@ to-report get-eligible-interactions [an-entity] if the-type = "observer"[ report map [first ?] filter [ table:get last ? "type" = "command" and - member? "O" table:get last ? "contexts" + member? "O" table:get last ? "contexts" + and table:get last ? "visible" ] table:to-list tasks ] ;; if it's an agentset, they can call turtle commands in their own model or observer commands in other models if the-type = "agentset"[ report map [first ?] filter [ - (table:get last ? "type" = "command" and + ((table:get last ? "type" = "command" and member? "T" table:get last ? "contexts" and table:get last ? "model" = table:get an-entity "model" ) or (table:get last ? "type" = "command" and member? "O" table:get last ? "contexts" and - table:get last ? "model" != table:get an-entity "model") + table:get last ? "model" != table:get an-entity "model")) + and table:get last ? "visible" ] table:to-list tasks ] if the-type = "value"[ report filter [ - table:get last ? "type" = "value" + table:get last ? "type" = "value" and + table:get last ? "visible" ] table:to-list tasks ]