Array Question?
BlitzPlus Forums/BlitzPlus Programming/Array Question?
| ||
Okay, what's the best way to find a line of identical data in an array's list. I've already got something working, with a (canny) few For... Next loops to check left/right/up/down and diagnally, up to 4 elements in the array, but this seems overkill. Is there a quicker way, because my mind cannot comprehend it at the moment... yep, I have a hangover! :) Thanks in advance Dabz |
| ||
Really the only way of doing it is loop through each cell and check if it in all directions. Of course a marginal optimisation would be to mark the ones checked so it won't do the same cell twice. That said connect 4 has so few cells in it I think you'd be hard pressed to call this a bottleneck. |
| ||
I presume you mean a 2D array or single array that's displayed as a 2D grid or something (you weren't entirely clear). But basically you only really need to check for horizontal/vertical and diagonal. shouldn't different checks for left and right, and for up and down... |
| ||
Thanks chaps, I sorted it... I've mangaged to check along all directions of the array. Which is nice. It's a weird feeling when you know how to do something, but you forget, and you try to dig it back out! :) lol Dabz |