Games Check Connected Points

Discussion in 'Game Development' started by Eme Fibonacci, Nov 23, 2018.

  1. Eme Fibonacci

    Eme Fibonacci Active Member Licensed 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?
     
  2. Gunther

    Gunther Active Member Licensed User

    Last edited: Nov 23, 2018
  3. sorex

    sorex Expert Licensed User

    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.
     
  4. Arthur Ávila

    Arthur Ávila Member Licensed User

    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.
     
  5. Eme Fibonacci

    Eme Fibonacci Active Member Licensed User

    Hello everyone. I'm trying to do this using "Connected Component Labeling" algorithm.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice