Re: Finding blocks of symbols on a 2dimensional array




"efialtis" <efialtis@xxxxxxxxxxx> wrote in message
news:pan.2006.01.09.16.41.59.756751@xxxxxxxxxxxxxx
> Hi to all,
>
> I am creating a program which plays a game. The game is played
> on a NxN square board. In every position of the board we may have
> a ball or not. Take for example the following 5x5 board ( x : ball,
> o : empty space).
>
> x x o o x
> x o o o o
> o o x x o
> o o o x x
> x x o o o
>
> I want to write a function which calculates the number of ball blocks
> on a specific board. For example the above board has 4 ball blocks
> (1 or more balls being surrounded by empty spaces).
>
> The problem is that i cannot think of any elegant algorithm to
> calculate this number.

Sounds like a 'convert to binary' and then do some bit twiddling to me.


.



Relevant Pages

  • Re: Finding blocks of symbols on a 2dimensional array
    ... > I am creating a program which plays a game. ... > o: empty space). ... For example the above board has 4 ball blocks ... int count_blocks{ ...
    (comp.lang.c)
  • Re: Finding blocks of symbols on a 2dimensional array
    ... > I am creating a program which plays a game. ... > o: empty space). ... For example the above board has 4 ball blocks ... > The problem is that i cannot think of any elegant algorithm to ...
    (comp.lang.c)
  • Finding blocks of symbols on a 2dimensional array
    ... I am creating a program which plays a game. ... on a NxN square board. ... o: empty space). ... I want to write a function which calculates the number of ball blocks ...
    (comp.lang.c)
  • Re: Condemned
    ... Not only does it look fantastic, but the game play is really fresh and different. ... You should be able to find it cheap now, so if you haven't played it yet, and like getting the crap scared out of you, get this game. ... One of the things that annoys me in these types of games is Sorry, it seriously breaks immersion when you peek around both sides of a doorway and see nothing but empty space, step through a door and then get a cutscene of you just sauntering through the doorway without a care in the world and get hit from behind from what you already know is an empty corner. ...
    (comp.sys.ibm.pc.games.action)