Reputation: 23
I want to program cell-division in Netlogo. I managed to program it in a way that the cells divide with a probability. This yields a specific stochastic function, which I will not bother you with.
However to make it as real-life as possible, I do not want multiple cells to be on the same patch. I managed to program this by letting some cells die, if they don't find a patch nearby that is empty. BUT this influences the stochastic function, because more cells die than are supposed to die.
Some help would be greatly appreciated.
My code for clarification:
to mitosis
ask stemcells [
if random-float (2 * r * lambda) < 2 * r * lambda [
ifelse random-float 1. < probability
[ hatch 1 [
let free-neighbor one-of neighbors with [not any? turtles-here]
ifelse free-neighbor != nobody [
move-to free-neighbor]
[ die] ]
set breed stemcells
] [ die ] ] ]
Upvotes: 1
Views: 388
Reputation: 96
The way I am following the logic of the code, you are asking each stemcell, based on "probability" whether it wants to divide.
The hatch code looks good, I pulled that out and it tests correctly: either find a neighbor patch or die.
But if your stemcell decides not to divide, it looks to me like it gets to the second [die]. Is this where your problem: "because more cells die than are supposed to die" comes from?
Also, the "set breed" is not needed, as the hatch in the ask will always create breed stemcell.
Added this from your recent comment:
"I want them to move and make way for the hatched cell if possible" ... except that your code is acting on the hatchling, so really, the newly hatched stemcell is doing the moving, not the original. If that matters.
I tested the entire line of code instead of just pulling out the over-crowding part, see if this helps. You'll need buttons to setup, to mitosis, and an output window to see the messages. Comments from me in the code include the original finding of the if statement by the original answerer.
breed [stemcells stemcell]
globals [
r
lambda
probability
]
to setup
clear-all
set r 0.5544
set lambda 1.233
set probability .85
create-stemcells 1
end
to mitosis
ask stemcells [
if random-float (2 * r * lambda) < 2 * r * lambda [ ;; this is superfluous, always true
ifelse random-float 1. < probability [
hatch 1 [
let free-neighbor one-of neighbors with [not any? turtles-here]
ifelse free-neighbor != nobody [
move-to free-neighbor
]
[; this die is executed if there is no free space in the neighborhood
output-show " Dead because of no free space in neighborhood"
die
]
]
;set breed stemcells ;; not necessary in an ask of stemcells
]
[;this die is executed if probablity compares to random-float and the hatch is not done
output-show " Dead because did not hatch"
die
]
]
]
e
Upvotes: 1
Reputation: 641
It looks like your problem is in the beginning where you have:
if random-float (2 * r * lambda) < 2 * r * lambda
Since random-float of any number x is always going to report a number from 0-x.
That will make random-float (x) < x
always be a true statement.
Upvotes: 1