Creating blink "pairs"

Hi all,

I’ve been rather enjoying tooling around with these little guys. I’ve created a little “memory” game as a jumping-off point (find matching pairs in the grid).

At the moment each Blink randomly selects its own colour during setup. This was just a temporary stopgap so I could move on and get the rest of it running, but I’d like to go back and fix it so that the setup generates coloured pairs of blinks (e.g. 2 red, 2 green, 2 blue etc). Ideally, these pairs wouldn’t necessarily always be adjacent.

I’m not sure how to tackle it – I can broadcast a message like “I am green, who’s with me?” easily enough, but what’s got me stuck is how to boil any responses back to a single “winner” without just randomly selecting a directly connected peer.

  • it should be possible for a match to be adjacent
  • it should also be equally possible for a match to be on the other side of the grid

Any advice/pointers? The networking stuff is the most interesting part of working with these but it’s also the part that completely bakes my noodle!

cheers
-O

1 Like

This is actually a non-trivial problem to solve giving the limitations of the platform. But in a general way there are lots of different solutions for this.

The easiest is simply to ask the user to set the Blinks in color pairs and them setup the "board whatever way they want).

Another a bit more ellaborate is to simply require a specific organization for the setup state (say, 2 rows of blinks all connected in a single cluster). Picking up a suitable arrangement and assuming the user will do the right thing turns this in a trivial problem (in the end the user would still be responsible to build the board).

Now to have a board assembled and them automatically filling the colors with your requirements most likely means that at least one Blink needs to know the full arrangement of the board (see recent question about this).

Thanks for the reply – it’s actually encouraging to know it’s not simple! I had considered manual setup but it felt like a cheat given the way most of the other games manage themselves.

My latest approach has been to walk a tree to allocate pairs based on direct proximity and then “shuffle” the tree once allocated. It works in my head, but applying it to the hardware is a different story :slight_smile:

1 Like