Friday, May 16, 2008

a mathematical problem

i played a game on my iphone the other day. one that i am sure most people have played some variation of at the least. it consisted of a grid made up of 9 columns and 10 rows of marbles. there were four types of marbles displayed on the grid. the object of the game was to remove all of the marbles by discarding sets that contained adjacent, similar marbles. by clicking one of the marbles in such set, all marbles of the set would be removed from the board and the marbles above this set would fall to fill the void. the set of pictures shows this action in process for removing two such groups from the grid.

the challenge of the game exists in two forms. the first, and simplest, is removing all of the marbles form the board. with some forethought and a bit of luck, this can be done without too much trouble. however, while playing the game, i realized that at some point in the endeavour, there would be a point of no return where the game would be lost with no hope of winning. i thought that a mathematical approach to the task may provide a solution to the game everytime.

while i have not seriously pondered a solution to this idea, i do have several leads. i could assign each square a value to be differentiated from all others. the most obvious solution would be the cartesian plane. then, each variance of marble would be assigned a variable to group the marbles into their four classes. the last step (and the hardest) would be to devise a recursive formula that would run through all possible outcomes for the provided grid much like a chess program does to play a game of chess.

while i have never attempted such a thing, it is not beyond my means to do so. i have lightly contemplated the proposed program but have yet to sit down and produce a skeleton.

while playing the game some more after realizing that this could be solved with programming, i realized that the game also awards a score to the player which is the second challenge. this score is not just the result of how many marbles are left on the grid at the end of the game, but is strongly linked to the order in which the marbles are removed. deleting large groups is far more rewarding than completing the task of a clean grid.

this lead me to realize that my previous idea for an automatic solver could be further enhanced by figuring out the socring method of the game and incorporating it into the program. this algorithm could find two things: the solution that would yield the highest possible score with no concern of the number of marbles left and the solution that would allow for the largest score while ensuring a clean grid at the end.

i say all of this to say that i think i have a fun project on my hands. my biggest problem is that i have no means of programming right now. i have niethern server space for php or ruby (not that it would do me any good anyway since i know very little of either of those) nor any interface to code in C++ or C#. i can still accomplish my task in theory using pseudo-code even if i can’t actually create the engine itself.

i’ll post if anything ever comes of this. it may just be a fanciful thought that goes away.

Play the game here.

Posted by at 07:05:20 | Permalink | Comments (3)