Hi,

I am trying to simulate animal movement in a gridded landscape made up of
cells. At each time step (iteration), the animal moves from one cell to
another in a random fashion.
This is how I am simulating movement, where a and b are the x,y co-ordinates
of the animal at the previous time step:

for (i in 1:no.of.steps){
direction <- sample(1:8, 1)

if(direction == 1){
a <- a
b <- b - 1}
if(direction == 2){
a <- a
b <- b + 1}
if(direction == 3){
a <- a - 1
b <- b}
if(direction == 4){
a <- a + 1
b <- b}
if(direction == 5){
a <- a - 1
b <- b + 1}
if(direction == 6){
a <- a + 1
b <- b + 1}
if(direction == 7){
a <- a + 1
b <- b - 1}
if(direction == 8){
a <- a - 1
b <- b - 1}

The problem is
1. I want to limit animals to a pre-defined circular home range
2. I want to limit animals to the borders of the landscape itself


I tried to limit animals to their home range using:

if (sqrt((x - a)^2 + (y - b)^2) > radius.range) {
a <- a[i-1]
b <- b[i-1]
}

Where x and y are co-ordinates for the centre of the home range

But this is not working - giving NA values for x and y co-ordinates. Does
anyone know what to do?

Thanks and cheers,
Umesh

	[[alternative HTML version deleted]]


