0

I want to ask if I want to ask female to hatch after X number of ticks. the female and male mated in March or April and give birth in January or February.

at the begining I made the code that they mate and have children in january and february

the code

 to-report parents-here? 
 report any? turtles-here with [gender = "male"]
     and
     any? turtles-here with [gender = "female"]
 end

to go
if ticks mod 12 <= 2 [
ask patches with [parents-here?] [
ask one-of turtles-here with [gender = "female"] [
  hatch 1 [
    set gender one-of ["male" "female"]
   ]
 ]
]
tick

end

but how can I ask them if parents here now so after exact number of ticks this female can hatch (pregnancy time) the problem that when I make gestaton 0 then + 1 they still count even after hatching.

Thanks in advance for the help and sorry for my bad English

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
Marwa
  • 159
  • 6
  • possible duplicate of [How can one create a countdown timer in Netlogo?](http://stackoverflow.com/questions/4296818/how-can-one-create-a-countdown-timer-in-netlogo) – Seth Tisue May 12 '14 at 13:32

1 Answers1

0

This may not be exactly what you're asking for, but you might be able to achieve the desired result by having a turtles own variable that you use as a gestation countdown:

turtles-own [ gestation ]

to-report parents-here? 
     report any? turtles-here with [gender = "male"]
            and
            any? turtles-here with [gender = "female"]
end

to go
    if ticks mod 12 <= 2 [
        ask patches with [parents-here?] [
            ask one-of turtles-here with [gender = "female"] [
                set gestation 10
            ]
        ]
    ]

    ask turtles with [gestation > 0] [
        if [gestation = 1] [
            hatch 1 [ set gender one-of ["male" "female"] ]
        ]
        set gestation (gestation - 1)
    ]

    tick
end
Frank Duncan
  • 358
  • 1
  • 5