Help with modelling - setting attributes

0 views
Skip to first unread message

howard...@gmail.com

unread,
Aug 28, 2009, 10:18:08 AM8/28/09
to The Modelling4All Project
I want to use

http://modelling4all.nsms.ox.ac.uk/Resources/Composer/en/MB.2/INITIALISE-ATTRIBUTE.html

to set multiple attributes e.g. like is happening here:

http://modelling4all.nsms.ox.ac.uk/Resources/Composer/en/MB.2/SET-WORLD-SIZE.html

but i don't understand the syntax.

i made a start here:

https://weblearn.ox.ac.uk/access/content/user/14894/SET-ATTRIBUTES

but can't see how to change the last line

Ken Kahn

unread,
Aug 28, 2009, 10:33:41 AM8/28/09
to modell...@googlegroups.com
Hi.

One way to do this all in one micro-behaviour is to edit to be

substitute-text-area-for the-power-s0 85 
substitute-text-area-for the-power-s3 5
substitute-text-area-for the-power-s4 3 
substitute-text-area-for the-power-s5 2
set my-power-s0 the-power-s0
set my-power-s3 the-power-s3
set my-power-s4 the-power-s4
set my-power-s5 the-power-s5
But perhaps a better way to do this is to copy INITIALISE-ATTRIBUTE 4 times. It is more modular (perhaps someone will want to add S1 or S2).
Best,
-ken
P.S. There is a trick to using substitute-text-area-for  -- the first argument should be the string that is replaced by a text box. So
substitute-text-area-for my-power-s0 85
or
substitute-text-area-for power-s0 85
would substitute the box for the first argument to SET rather than the desired secoond arg.

howard...@gmail.com

unread,
Aug 28, 2009, 10:45:49 AM8/28/09
to The Modelling4All Project
I changed the micro-behaviour as suggested but the behaviour composer
throws errors:
https://weblearn.ox.ac.uk/access/content/user/14894/SET-ATTRIBUTES

Could not find the-power-s0 in substitute-text-area-for the-power-s0
85 substitute-text-area-for the-power-s3 5 substitute-text-area-for
the-power-s4 3 substitute-text-area-for the-power-s5 2
Could not find my-power-s0 in substitute-text-area-for the-power-s3 5
substitute-text-area-for the-power-s4 3 substitute-text-area-for the-
power-s5 2

i tried changing the code to say my-power instead of the-power but
this brings the same error.

i prefer to set multiple attributes in one micro-behaviour simple to
keep the number of MBs smaller and make editing them all easier e.g.
need to click few times to change all attributes.

On Aug 28, 3:33 pm, Ken Kahn <toont...@googlemail.com> wrote:
> Hi.
> One way to do this all in one micro-behaviour is to edit to be
>
> substitute-text-area-for the-power-s0 85
> substitute-text-area-for the-power-s3 5
> substitute-text-area-for the-power-s4 3
> substitute-text-area-for the-power-s5 2
>
> set my-power-s0 the-power-s0
>
> set my-power-s3 the-power-s3
>
> set my-power-s4 the-power-s4
>
> set my-power-s5 the-power-s5
>
> But perhaps a better way to do this is to copy INITIALISE-ATTRIBUTE 4
> times. It is more modular (perhaps someone will want to add S1 or S2).
>
> Best,
>
> -ken
>
> P.S. There is a trick to using substitute-text-area-for  -- the first
> argument should be the string that is replaced by a text box. So
>
> substitute-text-area-for my-power-s0 85
>
> or
>
> substitute-text-area-for power-s0 85
>
> would substitute the box for the first argument to SET rather than the
> desired secoond arg.
>
> 2009/8/28 howard.no...@gmail.com <howard.no...@gmail.com>
>
>
>
> > I want to use
>
> >http://modelling4all.nsms.ox.ac.uk/Resources/Composer/en/MB.2/INITIAL...
>
> > to set multiple attributes e.g. like is happening here:
>
> >http://modelling4all.nsms.ox.ac.uk/Resources/Composer/en/MB.2/SET-WOR...

Ken Kahn

unread,
Aug 28, 2009, 11:30:49 AM8/28/09
to modell...@googlegroups.com
It seems that something inside of the Behaviour Composer is sensitive to improper HTML. I took your file and cleaned up some of the HTML and it works fine. Here it is.

Best,

-ken

<HTML>
<EM>I set a range of configurable attributes.</EM>
</H3>

<P>
<EM>Here we can initialise attributes relating to an agent e.g. a power-consuming&nbsp;device such as a com&nbsp;</EM>
</P>

<P><FONT color="#808080" size="2">Begin micro-behaviour</FONT> </P>

<P><STRONG>INITIALISE-ATTRIBUTES</STRONG> </P>

<p><font size="2" color="gray">Begin NetLogo code:</font></p>

<PRE>substitute-text-area-for the-power-s0 85
substitute-text-area-for the-power-s3 5
substitute-text-area-for the-power-s4 3
substitute-text-area-for the-power-s5 2
set my-power-s0 the-power-s0
set my-power-s3 the-power-s3
set my-power-s4 the-power-s4
set my-power-s5 the-power-s5
</PRE>

<p><font size="2" color="gray">End NetLogo code</font></p>

<H2>Variants</H2>

<P>Change the attributes above&nbsp;to any value (even a text string).</P><H2>How this works</H2><P>The BehaviourComposer treats specially variables whose name begins with "my-" or "my-next-". Typically micro-behaviours set the "my-next-" version and read from the "my-". Whenever the time advances the "my-" variable gets the value of the "my-next-" variable.</P><P>Note that, unlike NetLogo, you don't need to declare "breed" variables.</P><H2>History</H2><P>This was first&nbsp;implemented by Ken Kahn then adapted by Howard Noble.</P></HTML>&nbsp;

Reply all
Reply to author
Forward
0 new messages