Games Check Connected Points

Eme Fibonacci

Well-Known Member
Licensed User
Longtime User
If I have a 2D matrix (e.g. 9x9)
Columns(1-9) and Rows(1-9)

'111100100
'001000100
'001110100
'111000100
'001110001
'100000101
'111110001
'001011111
'111000000

How to check:
If points (1,1) and (5,5) are connected? (Yes)
If points (7,1) and (7,6) are connected? (No)
If points (1,9) and (9,5) are connected? (Yes)

This algorithm Seems complicated.

Any idea?
 
Last edited:
you need to iterate through all directions to see if there's a valid direction and if there is iterate again by calling the same sub again for the new position.
 
Probably the best way to do this is to use recursivity. I guess you could get some guidance looking for minesweeper or naval battle algorithms.
 
Back
Top