for(i=0; i<=5; i+=1){ for(j=0; j<=5; j+=1){ for(k=1; k<=2; k+=1;){ switch(field[i,j]==k){ case field[i+1,j]==k: switch(field[i,j]==k){ case field[i+1,j]==k: return true; case field[i-1,j]==k: return true; case field[i,j+1]==k: return true; case field[i,j-1]==k: return true;} case field[i-1,j]==k: switch(field[i,j]==k){ case field[i+1,j]==k: return true; case field[i-1,j]==k: return true; case field[i,j+1]==k: return true; case field[i,j-1]==k: return true; } case field[i,j+1]==k: switch(field[i,j]==k){ case field[i+1,j]==k: return true; case field[i-1,j]==k: return true; case field[i,j+1]==k: return true; case field[i,j-1]==k: return true; } case field[i,j-1]==k: switch(field[i,j]==k){ case field[i+1,j]==k: return true; case field[i-1,j]==k: return true; case field[i,j+1]==k: return true; case field[i,j-1]==k: return true; } } } } } /* q1=instance_position(50+(64*i),155+(64*j),obj_1); q2=instance_position(50+(64*i),155+(64*j),obj_1); q3=instance_position(50+(64*i),155+(64*j),obj_1); min(q1,q2,q3); */The field array is the grid that im trying to find the connections on, var i is the x axis and var j is the y axis. k is the instance type (eg, obj1, obj2, etc..), starting at one. the code only needs to find if an instance is next to it, or above it, not on the diagonal. and it only needs to find an instance that is the same object as it.

the commented code is something i was trying out to try and figure out the youngest instance, the numbers in there are used to get the x and y co-ords as they are not stored in the field array. the field array is used to store if something is in there or not. (now that i read this, it seems kinda hard to understand, the i and j vars represent the x and y positions in the array, if you know what i mean.)

So does any one have any ideas on how i can make it work?

i was thinking once i have found the youngest instance, i can store it's co-ords in a temp var, delete the touching instances, then set the instance represented by k+1 into co-ords previously occupied by the youngest instance.

also, how would i be able to go about checking more than 3 instances?

sorry if this is hard to understand. thankyou very much for any help in advance.

Mitch