now this would work for connect four as well as other puzzle games
For dir=0 To 3 amount=1 For sign=-1 To +1 Step 2 x=newpiecex y=newpiecey Repeat x=x+Ceil(Cos(dir*45))*sign y=y+Ceil(Sin(dir*45))*sign If outofgridboundary(x,y) Then Exit If grid(x,y)<>newpieceteam Then Exit amount=amount+1 Forever Next ;here is where the amount is finished adding, for this direction ;just to clarify ;dir 0 is right and left ;dir 1 is upleft and downright ;dir 2 is up and down ;dir 3 is upright and downleft ;ex. if dir is 0 and amount is 3, then the new piece created a horizontal 3-in-a-row Next