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

Re: [netlogo-users] Breeding a new generation.

Expand Messages
  • James Steiner
    In addition to directly testing ticks, as Keith suggests, you can also use the ticks for periodic events using the MOD operator. ;; every 13 ticks, go
    Message 1 of 5 , Oct 31, 2012
    • 0 Attachment

      In addition to directly testing ticks, as Keith suggests,  you can also use the ticks for periodic events using the MOD operator.

      ;; every 13 ticks, go shopping
      IF TICKS MOD 13 = 0 [ GO-SHOPPING ]

      ~~James

      On Oct 31, 2012 6:21 PM, "Keith Ramey" <keithramey@...> wrote:
      [ snip ]
      > >3) Is there any way to use the current number of ticks as a global time? Eg after 1000 ticks do x, after 2000 ticks do y
      > You could do "if ticks > 1000 [do whatever]".  Someone else may have a more elegant answer.  Do you realize you are not advancing the tick counter in your model?
      >
      > Hth,
      > Keith

    • Keith Ramey
      Also, discovered another problem with my logic in #1. If you select two mice to breed as I suggested then add another mouse, you have changed your original
      Message 2 of 5 , Nov 1, 2012
      • 0 Attachment
        Also, discovered another problem with my logic in #1.  If you select two mice to breed as I suggested then add another mouse, you have changed your original agentset so that you can no longer choose from it again.  i.e. if you want to get all the  breeding pairs from the surviving mice that you can, you probably need to promote them to another breed such as survivors.  After executing the mice that did not make it, you could do something like this:

        ask mice [ set breed survivors ]
        while [count survivors > 1] [
          let survivors-pair n-of 2 survivors ;; creates a breeding pair agentset
          ;; you need to spawn your new mice based on the surviving-pair agentset
          ;; you need to convert your surviving-pair back to mice or kill them so that they can't be chosen again
        ]
        ask survivors [;; die or change back to mice since there could be one odd survivor left]

        I think something like this should work...

        Hth,
        Keith


        From: James Steiner <gregortroll@...>
        To: netlogo-users@yahoogroups.com
        Sent: Thu, November 1, 2012 7:47:25 AM
        Subject: Re: [netlogo-users] Breeding a new generation.

         

        In addition to directly testing ticks, as Keith suggests,  you can also use the ticks for periodic events using the MOD operator.

        ;; every 13 ticks, go shopping
        IF TICKS MOD 13 = 0 [ GO-SHOPPING ]

        ~~James

        On Oct 31, 2012 6:21 PM, "Keith Ramey" <keithramey@...> wrote:
        [ snip ]
        > >3) Is there any way to use the current number of ticks as a global time? Eg after 1000 ticks do x, after 2000 ticks do y
        > You could do "if ticks > 1000 [do whatever]".  Someone else may have a more elegant answer.  Do you realize you are not advancing the tick counter in your model?
        >
        > Hth,
        > Keith

      • solatario_hunter
        Thanks for all the help so far, I went a slightly different way but your Keiths 1st message was the inspiration for my idea. I got my mating model to work
        Message 3 of 5 , Nov 1, 2012
        • 0 Attachment
          Thanks for all the help so far, I went a slightly different way but your Keiths 1st message was the inspiration for my idea. I got my mating model to work quite well - http://chrisheadleand.com/netlogo/mating.html - however The offspring should be set to mature = false (to stop them from breeding) however if I slow the model down its obvious the offspring are breeding... Im not sure that should be possible based on my code.

          I then tried to take my mating model (flawed though it is) into my random population model. What should happen is this

          1) Mice should move across the screen based on their behavior. If they dont get there by 2000 moves they should die.
          2) If they get to the other side of the screen (the red zone) they should stay there and scutter around looking for a mate (based on the mating model above)
          3) If they have managed to get to the redzone, and the population has reduced below 200 (the base population) they should breed if they find a mate.

          http://chrisheadleand.com/netlogo/evolution.html

          However... when they get to the redzone they don't stay there and look for a mate.. based on my code I'm not sure how this is possible. Also... if they find a mate I get the following error

          --

          error while mouse 68 running IN-RADIUS in procedure MATE
          called by procedure GO
          IN-RADIUS expected input to be an agentset but got the turtle (mouse 132) instead.
          (halted running of go)

          --

          Im really stumped by these problems... have I just made a simple error or is what I'm trying to do just not possible?

          Thanks again, the communities support has been invaluable!

          CJ


          --- In netlogo-users@yahoogroups.com, Keith Ramey <keithramey@...> wrote:
          >
          > Also, discovered another problem with my logic in #1. If you select two mice to
          > breed as I suggested then add another mouse, you have changed your original
          > agentset so that you can no longer choose from it again. i.e. if you want to
          > get all the breeding pairs from the surviving mice that you can, you probably
          > need to promote them to another breed such as survivors. After executing the
          > mice that did not make it, you could do something like this:
          >
          > ask mice [ set breed survivors ]
          > while [count survivors > 1] [
          > let survivors-pair n-of 2 survivors ;; creates a breeding pair agentset
          > ;; you need to spawn your new mice based on the surviving-pair agentset
          > ;; you need to convert your surviving-pair back to mice or kill them so that
          > they can't be chosen again
          > ]
          > ask survivors [;; die or change back to mice since there could be one odd
          > survivor left]
          >
          > I think something like this should work...
          >
          > Hth,
          > Keith
          >
          >
          >
          >
          > ________________________________
          > From: James Steiner <gregortroll@...>
          > To: netlogo-users@yahoogroups.com
          > Sent: Thu, November 1, 2012 7:47:25 AM
          > Subject: Re: [netlogo-users] Breeding a new generation.
          >
          >
          > In addition to directly testing ticks, as Keith suggests, you can also use the
          > ticks for periodic events using the MOD operator.
          >
          > ;; every 13 ticks, go shopping
          > IF TICKS MOD 13 = 0 [ GO-SHOPPING ]
          > ~~James
          > On Oct 31, 2012 6:21 PM, "Keith Ramey" <keithramey@...> wrote:
          > [ snip ]
          > > >3) Is there any way to use the current number of ticks as a global time? Eg
          > >after 1000 ticks do x, after 2000 ticks do y
          > > You could do "if ticks > 1000 [do whatever]". Someone else may have a more
          > >elegant answer. Do you realize you are not advancing the tick counter in your
          > >model?
          > >
          > > Hth,
          > > Keith
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.