I was listening to Tim Ferris interview Jane McGonigal on the neuro-programming that occurs around playing games. One of the games mentioned was Candy Crush Saga. Curious, I decided to start playing it – and now I find it relaxing, a good place to put my mind when my mind is obsessing about other things.
But of course, being me, I started to wonder, “can I program a solution for this?” Well, of course not – the boards are actually random – but I could write a helper to detect available moves, and possibly future moves.
Turns out a guy already wrote one. See his video explaining how it works here. However, I couldn’t get it to run, and it required me running candy crush on my laptop. And, it didn’t look ahead moves – just the currently available ones. Still, an impressive piece of work.
So I started coding one for fun. I started with this screen:
Question: How many possible moves do you see? (A move for the uninitiated, is swapping adjacent candies so they form at least 3 in a row or 3 in a column). I counted 11 on my initial count.
Here’s what it found:
- Yeah. Bug in my code. I thought I was doing a copy from one board to another, but it was a shallow copy, so all the “possible” moves were being remembered one after the other, rather than one at a time. PANDA-MONIUM!
My attempted fix of the code didn’t work. And its getting late.
I believe the test needs to Assert(13, allPossibleMoves.Count):
Or am I missing something? I will resume this.. some day.
In the mean time, it raises interesting things like:
- How to represent a very complicated system in a way that makes sense while developing?
- How to load test data into complicated systems?
Happy crushes. I’m at level 35, FWIW.
Oh, and I’m using the test-adapter to run NUnit Tests using Microsoft’s test-running tools.