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.
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.
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?