determine if opposing pieces are captivated

Discussion in 'C' started by vril, Mar 3, 2013.

  1. vril

    vril New Member

    Joined:
    Mar 3, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hey everyone. I am trying to write a simple application in C that resembles the game "Computer Co", but I am stuck with this problem: If the board is represented by a dimensional array, with what algorithm could I tell if one player's pieces are captivated by the other's? In other words, how can I recognise whether the pieces of one colour form a circle?
    Sorry for my English.
     
  2. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    I've never heard of the game - what's it similar to? From your description, you'd probably need piece and their coordinate info.

    If your board is a 2D grid, then it's pretty much

    Code:
       s2
    s2 s1 s2
       s2
    
    Code:
    if(s1.row - 1 == s2[index].row && 
       s1.col - 1 == s2[index].col && 
       s1.row + 1 == s2[index].row &&
       s1.col + 1 == s2[index].col)
       // this s1 is encircled by s2(s)
    
    I don't always interpret things the way they're intended though - it's only a guess as to what you're trying to do. This would be checking one piece against the opposing side probably through a loop of s2 pieces.
     
  3. vril

    vril New Member

    Joined:
    Mar 3, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks.
    Is there any source code of the game, bacause I cannot find anything?
     
  4. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Which game? I don't know what "Computer co" is. The bit I posted was something similar to what I had done... do you mean that?
     

Share This Page

  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