[Tutor] recursion sort of

Jennifer Cianciolo jciancio@indiana.edu
Thu May 29 15:56:53 2003


Hi all,

I'm trying to write a little program on population growth (of
anything, say plants).  The key is that it's frequency dependent. 
When the size is large, individuals don't do as well, and then when
it's smaller, they do better.  also there are 2 'types' of individuals
(here called n1 and n2; 'w' is how well they do)

Here it is so far:

def run(n1, n2):
    while n1>=501:
        w=1
        n1=n1*w
    while n1<=500:
        w=0.2
        n1=n1*W
    while n2>=501:
        w=0.8
        n2=n2*w
    while n2<=500:
        w=0.4
        n2=n2*W
    nt=n2+n1
    print nt

now 2 problems, it is making python freeze again, and I'm sure if I
could run it like this it would say n2 is called before it is defined
(or something like that) but I don't think I want to put it in the
loop, do I?
I would also want it to keep measuring nt over time, but I think I can
work on that more myself, if I can get around getting it to calculate
nt once in the first place.

Any suggustions?
I hope this isn't too vague.

thanks in advance
Jen