Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for specifying the scope of a function and fields: observer(global) and agent #5

Closed
GoogleCodeExporter opened this issue Apr 9, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

Why is the new feature important:
Right now all functions are called in the agent scope. The current 
code-generation works as:

to go
  ask nodes [
    function 1 //if function 1 is intended to run at the beginning and already has an "ask nodes". Execution results in an error always.
    function 2 //agent-level function
    ...
    function n // agent-level function
  ]
]

Describe the new feature:
The scope of the fields and functions should be specified by the user:

global_fields: // global fields
        - transRange constant 10
        - roundLength constant 20
        - glowTime constant 5
agent_fields: // agent (local) fields
        - mycolor 0
        - clock random[1 20]
agent_action_primitives:
        - setClock(glowTime)
agent_returning_primitives:
        - countLocal(mycolor 10)
observer_primitives: // or global primitives: should not be enclosed in "ask 
nodes" 
    - begin moveRandomWalk(.1)
    - begin updateNetworkGraph(transRange)
    - end updateColor(glowTime)
    - end incrementAgentsClocks(roundLength)

This results into:

globals [
      transRange
      roundLength
      glowTime
]

breed [nodes node]

nodes-own [
      mycolor
      clock
]

to setup
     set transRange 10
     set roundLength 20
     set glowTime 5

     create-nodes [
        set mycolor 0
        set clock 1 + random 19
     ]

end

to go
    //handle max tick
    begin moveRandomWalk(.1)  // observer function call
    begin updateNetworkGraph(transRange) // observer function call

    ask nodes [ // agent-scope functions - here you play with all possible combinations
        setClock(glowTime)
        countLocal(mycolor 10)
        ....
    ]

    end updateColor(glowTime) // observer function call
    end incrementAgentsClocks(roundLength) // observer function call
end

Original issue reported on code.google.com by andrei.p...@gmail.com on 12 Dec 2011 at 11:31

@GoogleCodeExporter
Copy link
Author

There might be some syntax errors above: like the begin/end keywords that 
should not be there. 

Original comment by andrei.p...@gmail.com on 12 Dec 2011 at 11:41

@GoogleCodeExporter
Copy link
Author

I think this is solved by static global primitives, can you confirm this Andrei?

Original comment by sjorsvan...@gmail.com on 20 Jan 2012 at 4:30

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Yes. Confirmed !

Original comment by andrei.p...@gmail.com on 20 Jan 2012 at 4:49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant