Loading ...
Sorry, an error occurred while loading the content.

Re: Slider and Switch Combinations?

Expand Messages
  • sanbalestrini
    Hey Don, Sorry about that, I misunderstood. But there might be a problem in your new code. What is doing now is asking every turtle to ask 30 turtles in turn
    Message 1 of 5 , May 1, 2009
    • 0 Attachment
      Hey Don,

      Sorry about that, I misunderstood. But there might be a problem in your new code.

      What is doing now is asking every turtle to ask 30 turtles in turn to turn their WEI to a random number if WEI-filter is on. (As a side note, I noticed that is common practice in NetLogo to add a '?' at the end of boolean variables, so you could call the filter WEI? in the switch to make it more succinct). Is WEI-filter the global boolean? Or is it an internal variable for each turtle? If it is global, then you probably just want to have:

      if WEI-Filter = true [ ask n-of 30 turtles [set WEI num-WEI] ]

      for your last line.

      Cheers!

      -Santiago

      PS: You shouldn't need to put the '= true' either, since it is boolean, it will already evaluate to true or false.

      --- In netlogo-users@yahoogroups.com, "Braxton, Donald (BRAXTON)" <braxton@...> wrote:
      >
      > Hi Santiago:
      >
      > Thanks for the response, I tried it but I still got the same basic problem, namely, it said the WEI had to be a boolean value because of the switch. This finally brought home to me that i really only needed to make the name of switch something different from the name of the variable. Hence, this code worked where the others didn't.
      >
      > to setup
      >
      > clear-all
      >
      > ;; Set up 100 agents with seeded PerceptBias and TAI.
      >
      > ask n-of 100 patches [ sprout 1 ]
      > ask turtles [ set shape "person" set color yellow set PerceptBias -5 + random 10 set WEI random 10 ]
      > ask turtles [ if WEI-Filter = true [ ask n-of 30 turtles [set WEI num-WEI] ] ]
      >
      > end
      >
      > Note it combined your more elegant ordering recommendation with the simple name change and all was well.
      >
      > Thanks!
      >
      > Don
      > ________________________________________
      > From: netlogo-users@yahoogroups.com [netlogo-users@yahoogroups.com] On Behalf Of sanbalestrini [no_reply@yahoogroups.com]
      > Sent: Tuesday, April 28, 2009 1:09 PM
      > To: netlogo-users@yahoogroups.com
      > Subject: [netlogo-users] Re: Slider and Switch Combinations?
      >
      > Hey Don,
      >
      > Why not reverse it so you first set all turtles to have a random WEI, and then if you are using WEI, randomly pick 30 and set their WEI to num-WEI? E.g.,
      >
      > ask n-of 100 patches [ sprout 1 ]
      > ask turtles
      > [ set shape "person"
      > set color yellow
      > set PerceptBias -5 + random 10
      > set WEI random 10 ]
      > if WIE [ ask n-of 30 turtles [set WEI num-WEI] ]
      >
      > Cheers!
      >
      > -Santiago
      >
    • Braxton, Donald (BRAXTON)
      Hi Santiago: You are exactly right with the code problem. I implemented the older code and noted right away that I needed to place the global boolean outside
      Message 2 of 5 , May 2, 2009
      • 0 Attachment
        Hi Santiago:

        You are exactly right with the code problem. I implemented the older code and noted right away that I needed to place the global boolean outside the ask command. All the turtles were assigned WEI-num value rather than only the designated ones. Nice catch!

        You guys are so good you see my mistakes before I even implement them myself!

        Always a pleasure. And much appreciated!

        Don
        ________________________________________
        From: netlogo-users@yahoogroups.com [netlogo-users@yahoogroups.com] On Behalf Of sanbalestrini [no_reply@yahoogroups.com]
        Sent: Friday, May 01, 2009 8:02 AM
        To: netlogo-users@yahoogroups.com
        Subject: [netlogo-users] Re: Slider and Switch Combinations?

        Hey Don,

        Sorry about that, I misunderstood. But there might be a problem in your new code.

        What is doing now is asking every turtle to ask 30 turtles in turn to turn their WEI to a random number if WEI-filter is on. (As a side note, I noticed that is common practice in NetLogo to add a '?' at the end of boolean variables, so you could call the filter WEI? in the switch to make it more succinct). Is WEI-filter the global boolean? Or is it an internal variable for each turtle? If it is global, then you probably just want to have:

        if WEI-Filter = true [ ask n-of 30 turtles [set WEI num-WEI] ]

        for your last line.

        Cheers!

        -Santiago

        PS: You shouldn't need to put the '= true' either, since it is boolean, it will already evaluate to true or false.

        --- In netlogo-users@yahoogroups.com<mailto:netlogo-users%40yahoogroups.com>, "Braxton, Donald (BRAXTON)" <braxton@...> wrote:
        >
        > Hi Santiago:
        >
        > Thanks for the response, I tried it but I still got the same basic problem, namely, it said the WEI had to be a boolean value because of the switch. This finally brought home to me that i really only needed to make the name of switch something different from the name of the variable. Hence, this code worked where the others didn't.
        >
        > to setup
        >
        > clear-all
        >
        > ;; Set up 100 agents with seeded PerceptBias and TAI.
        >
        > ask n-of 100 patches [ sprout 1 ]
        > ask turtles [ set shape "person" set color yellow set PerceptBias -5 + random 10 set WEI random 10 ]
        > ask turtles [ if WEI-Filter = true [ ask n-of 30 turtles [set WEI num-WEI] ] ]
        >
        > end
        >
        > Note it combined your more elegant ordering recommendation with the simple name change and all was well.
        >
        > Thanks!
        >
        > Don
        > ________________________________________
        > From: netlogo-users@yahoogroups.com<mailto:netlogo-users%40yahoogroups.com> [netlogo-users@yahoogroups.com<mailto:netlogo-users%40yahoogroups.com>] On Behalf Of sanbalestrini [no_reply@yahoogroups.com<mailto:no_reply%40yahoogroups.com>]
        > Sent: Tuesday, April 28, 2009 1:09 PM
        > To: netlogo-users@yahoogroups.com<mailto:netlogo-users%40yahoogroups.com>
        > Subject: [netlogo-users] Re: Slider and Switch Combinations?
        >
        > Hey Don,
        >
        > Why not reverse it so you first set all turtles to have a random WEI, and then if you are using WEI, randomly pick 30 and set their WEI to num-WEI? E.g.,
        >
        > ask n-of 100 patches [ sprout 1 ]
        > ask turtles
        > [ set shape "person"
        > set color yellow
        > set PerceptBias -5 + random 10
        > set WEI random 10 ]
        > if WIE [ ask n-of 30 turtles [set WEI num-WEI] ]
        >
        > Cheers!
        >
        > -Santiago
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.