You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
937 B

function lotkavolterra() {
int goats := 100;
int tigers := 4;
int dwellTime := 0;
int curTime := 0;
int b := 0;
while(tigers > 0 & goats > 0) {
dwellTime := 0;
b := 1;
if(goats > 0 & tigers > 0) {
// geometric distribution with p = 0.5
while (b >= 1) {
{b := 1;} [0.5] {b := 0;}
dwellTime := dwellTime + 1;
}
curTime := curTime + dwellTime;
{tigers := tigers + 1;} [0.2] {{goats := goats - 1;} [0.1] {tigers := tigers - 1;}}
} else { if(goats > 0) {
// geometric distribution with p = 0.5
while (b >= 1) {
{b := 1;} [0.5] {b := 0;}
dwellTime := dwellTime + 1;
}
curTime := curTime + dwellTime;
goats := goats + 1;
} else { if(tigers > 0) {
// geometric distribution with p = 0.5
while (b >= 1) {
{b := 1;} [0.5] {b := 0;}
dwellTime := dwellTime + 1;
}
curTime := curTime + dwellTime;
tigers := tigers - 1;
} } }
}
}