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

Re: HubNet - making list from players choice

Expand Messages
  • marius
    It also seems that the turtles (players) are shuffled each time before being asked to report their choice values. For example, in the code below, although
    Message 1 of 5 , Sep 1, 2010
    • 0 Attachment
      It also seems that the turtles (players) are shuffled each time before being asked to report their choice values. For example, in the code below, although players are selected and ordered, the bid and demand list do not have the same order. The player 0 bid can be the first in the bid list, while his demand is the second in the demand list. When later combined and sorted, the outcome is not what it should be.
      Any idea would be greatly appreciated.
      Marius

      if any? players with [ color = red]
      [foreach sort-by [?1 < ?2] players with [ color = red]
      [ask ?
      [
      set $bid_list [$bid] of players with [ color = red ]
      set demand_list [Q_bid] of players with [ color = red ]
      set combined_d (map [list ?1 ?2] $bid_list demand_list)
      set sorted_d sort-by [first ?1 > first ?2] combined_d
      set $bid_list map [first ?] sorted_d
      set demand_list map [item 1 ?] sorted_d
      ]
      ]
      ]

      --- In netlogo-users@yahoogroups.com, "marius" <m_cutlac@...> wrote:
      >
      > Hi,
      >
      > The code below is part of HubNet model. Each player places a Q_bid, and we need to collect the positive ones only. However, the model collects the zero bids too. I guess I could drop the 0-s from the list but I imagine there is a simpler solution. Or, other suggestion to make lists from players choices?
      >
      > (Players have 90 seconds to adjust sliders that represent bids. We need to collect only the last value of the slider before the time expires).
      >
      > to process-demand ; turtle procedure
      > if Q_bid > 0
      > [ set demand_list [ Q_bid ] of players
      > ]
      > end
      >
      > Thanks.
      >
    • James Steiner
      It looks like you want to build is a list of red players, sorted by $bid. Once you have that you can, if you really need to, map it into lists of the bids and
      Message 2 of 5 , Sep 2, 2010
      • 0 Attachment
        It looks like you want to build is a list of red players, sorted by
        $bid. Once you have that you can, if you really need to, map it into
        lists of the bids and lists of the demands, retaining the sorted
        order.

        This is how you do that:

        let high-bid-first []
        let red-players players with [ color = red ]
        if any? red-players
        [ set high-bid-fist sorted-by [ [ $bid] of ?1 > [ $bid ] of ?2 ] red-players
        ]

        At this point high-bid-first is a list of players, ordered by $bid.

        In your example, you seem to be double looping when you don't need to.
        What I mean is that you are looping through the players, and making
        each player do the work that makes a pair of lists, sorted by $bid. It
        looks like each player doesn't make any player-specific changes to the
        list.

        In this case, it would save a lot of effort if the list of players
        sorted by $bid was made once, and then (if needed )used by the
        players.

        As a related note: It's often most useful to retain agents in the form
        of agents, when making lists and such of their properties, for the
        reason that it is then simple to access the other
        variables/properties, or access the original agents.

        ~~James




        First, It looks like you want to have the players act in their
        "native" order (since in that first sort-by ?1 and ?2 refer to the
        player turtles themselves.

        In that case, you don't need sort by, just sort is enough.

        The next thing you do is a little confusing... it looks like you
        intendare making every red player (the outer foreach)

        Don't make a list of the bids and demands, just gather the set of red players.
        Then, when you need to access the bids and demands, use [ ] of whoeve



        On Wed, Sep 1, 2010 at 1:43 PM, marius <m_cutlac@...> wrote:
        > It also seems that the turtles (players) are shuffled each time before being asked to report their choice values. For example, in the code below, although players are selected and ordered, the bid and demand list do not have the same order. The player 0 bid can be the first in the bid list, while his demand is the second in the demand list. When later combined and sorted, the outcome is not what it should be.
        > Any idea would be greatly appreciated.
        > Marius
        >
        > if any? players with [ color = red]
        >   [foreach sort-by [?1 < ?2] players with [ color = red]
        >    [ask ?
        >      [
        >        set $bid_list [$bid] of players with [ color = red ]
        >        set demand_list [Q_bid] of players with [ color = red ]
        >        set combined_d (map [list ?1 ?2] $bid_list demand_list)
        >        set sorted_d sort-by [first ?1 > first ?2] combined_d
        >        set $bid_list map [first ?] sorted_d
        >        set demand_list map [item 1 ?] sorted_d
        >        ]
        >      ]
        >   ]
        >
        > --- In netlogo-users@yahoogroups.com, "marius" <m_cutlac@...> wrote:
        >>
        >> Hi,
        >>
        >> The code below is part of HubNet model. Each player places a Q_bid, and we need to collect the positive ones only. However, the model collects the zero bids too. I guess I could drop the 0-s from the list but I imagine there is a simpler solution. Or, other suggestion to make lists from players choices?
        >>
        >> (Players have 90 seconds to adjust sliders that represent bids. We need to collect only the last value of the slider before the time expires).
        >>
        >> to process-demand ; turtle procedure
        >>   if Q_bid > 0
        >>   [ set demand_list [ Q_bid ] of players
        >>     ]
        >> end
        >>
        >> Thanks.
        >>
      • James Steiner
        I think you don t mean [Q_bid ] of players, here. That would create a list of all players q_bid values. Maybe you should, instead of collecting q_bids of
        Message 3 of 5 , Sep 2, 2010
        • 0 Attachment
          I think you don't mean [Q_bid ] of players, here. That would create a
          list of all players q_bid values.

          Maybe you should, instead of collecting q_bids of players where q_bid
          is greater than zero, just collect the players themselves...

          In other words, collect either a player or nobody. Then use that set.

          to-report bidder
          ifelse q_bid > 0 [ report self ] [ report nobody ]
          end

          Then a call like

          set bidder-list sort filter [ is-turtle? ? ] ([ bidder ] of players)

          creates a list of turtles that have q_bid > 0.

          Of course, you could just use:

          sort players with [ q_bid > 0 ]

          and get a similar list without all the other mumbo-jumbo.

          ~~James
          On Tue, Aug 31, 2010 at 12:05 PM, marius <m_cutlac@...> wrote:
          > Hi,
          >
          > The code below is part of HubNet model. Each player places a Q_bid, and we need to collect the positive ones only. However, the model collects the zero bids too. I guess I could drop the 0-s from the list but I imagine there is a simpler solution. Or, other suggestion to make lists from players choices?
          >
          > (Players have 90 seconds to adjust sliders that represent bids. We need to collect only the last value of the slider before the time expires).
          >
          > to process-demand ; turtle procedure
          >  if Q_bid > 0
          >  [ set demand_list [ Q_bid ] of players
          >    ]
          > end
          >
          > Thanks.
        • Marius Cutlac
          Hi James, Thanks for the answer. I need the sorted order, as I want to obtain sorted $bid list. The double looping was an attempt to make sure that the order
          Message 4 of 5 , Nov 5, 2010
          • 0 Attachment
            Hi James,
            Thanks for the answer. I need the sorted order, as I want to obtain sorted $bid list. The double looping was an attempt to make sure that the order was consistent from run to run, as it appears the model was shuffling the order (each player is represented as a turtle). Anyway, I am good to make the list of players, but I do not know how to produce/ display the list of $bid itself. This list is used further down in the model, and it has to retain the order of $bid and player ID.  You suggested the map primitive, but the examples in the manual are not helpful enough.
             
            Cheers,
            Marius
             

             


            From: James Steiner <gregortroll@...>
            To: netlogo-users@yahoogroups.com
            Sent: Thu, September 2, 2010 2:57:29 PM
            Subject: Re: [netlogo-users] Re: HubNet - making list from players choice

             

            It looks like you want to build is a list of red players, sorted by
            $bid. Once you have that you can, if you really need to, map it into
            lists of the bids and lists of the demands, retaining the sorted
            order.

            This is how you do that:

            let high-bid-first []
            let red-players players with [ color = red ]
            if any? red-players
            [ set high-bid-fist sorted-by [ [ $bid] of ?1 > [ $bid ] of ?2 ] red-players
            ]

            At this point high-bid-first is a list of players, ordered by $bid.

            In your example, you seem to be double looping when you don't need to.
            What I mean is that you are looping through the players, and making
            each player do the work that makes a pair of lists, sorted by $bid. It
            looks like each player doesn't make any player-specific changes to the
            list.

            In this case, it would save a lot of effort if the list of players
            sorted by $bid was made once, and then (if needed )used by the
            players.

            As a related note: It's often most useful to retain agents in the form
            of agents, when making lists and such of their properties, for the
            reason that it is then simple to access the other
            variables/properties, or access the original agents.

            ~~James

            First, It looks like you want to have the players act in their
            "native" order (since in that first sort-by ?1 and ?2 refer to the
            player turtles themselves.

            In that case, you don't need sort by, just sort is enough.

            The next thing you do is a little confusing... it looks like you
            intendare making every red player (the outer foreach)

            Don't make a list of the bids and demands, just gather the set of red players.
            Then, when you need to access the bids and demands, use [ ] of whoeve

            On Wed, Sep 1, 2010 at 1:43 PM, marius <m_cutlac@...> wrote:

            > It also seems that the turtles (players) are shuffled each time before being asked to report their choice values. For example, in the code below, although players are selected and ordered, the bid and demand list do not have the same order. The player 0 bid can be the first in the bid list, while his demand is the second in the demand list. When later combined and sorted, the outcome is not what it should be.
            > Any idea would be greatly appreciated.
            > Marius
            >
            > if any? players with [ color = red]
            >   [foreach sort-by [?1 < ?2] players with [ color = red]
            >    [ask ?
            >      [
            >        set $bid_list [$bid] of players with [ color = red ]
            >        set demand_list [Q_bid] of players with [ color = red ]
            >        set combined_d
            (map [list ?1 ?2] $bid_list demand_list)
            >        set sorted_d sort-by [first ?1 > first ?2] combined_d
            >        set $bid_list map [first ?] sorted_d
            >        set demand_list map [item 1 ?] sorted_d
            >        ]
            >      ]
            >   ]
            >
            > --- In netlogo-users@yahoogroups.com, "marius" <m_cutlac@...> wrote:
            >>
            >> Hi,
            >>
            >> The code below is part of HubNet model. Each player places a Q_bid, and we need to collect the positive ones only. However, the model collects the zero bids too. I guess I could drop the 0-s from the list but I imagine there is a simpler solution. Or, other suggestion to make lists from players choices?
            >>
            >>
            (Players have 90 seconds to adjust sliders that represent bids. We need to collect only the last value of the slider before the time expires).
            >>
            >> to process-demand ; turtle procedure
            >>   if Q_bid > 0
            >>   [ set demand_list [ Q_bid ] of players
            >>     ]
            >> end
            >>
            >> Thanks.
            >>


          Your message has been successfully submitted and would be delivered to recipients shortly.