There are a number of solutions (I can, at the moment, say there are a minimum of 6; but, there are probably more like a dozen or so); and I am not counting rotations/mirrors/etc.
how does this line works, you control if any of the cells got zero, otherwise it return; but where it returns? cause next line is Greenfoot.stop(); why doesnt it stop there?
@Pointifix, the 'return' statement causes an immediate exit (return back to the calling statement). No statements beyond it are executed if the 'return' statement is executed.
I set up an array called 'board' to hold int values for each gridsquare of the board. Then anytime I find a piece, all gridsquares that are covered by the blue portion of its image are incremented in the array. Immediately upon incrementing, I check to see if more than one blue section of a piece resides at that gridsquare, and a 'return' is executed if that was the case. If I made it through that for loop then I check to see if all the gridsquares got one hit (a value of zero meant that the puzzle was not completed yet). Again, if any array element was not incremented to one, then a 'return' is executed and the running of the scenario continues because the 'stop' statement has no been executed yet.
@Pointifix, I used 'if' also. I just used it in a different way than what you would have. You might have declared a local boolean, call it 'puzzleIncomplete', and 'if' detected puzzle incomplete in 'for' loop, set it to true. Then after the 'for', if the boolean was still false, stop the scenario.
@Pointifix, another option: declare a local int, call it 'count'. Have the for loop add all the gridsquare values into the 'count' variable. Afterwards, if its value is sixty, stop the scenario.
Anyway, the main difference is, you would stop the scenario 'if' and I am continuing the scenario 'if' (using the opposite check, of course).
The reason I did it this way, is because once you find that the puzzle has not been completed, you should not have to process anything else; so, just jumping out of the method would seem appropriate if (1) not all pieces were in the rectangle, (2) more than one blue section of a piece covered the same gridsquare, and (3) any gridsquare was not covered. Granted, I must be careful not to place any more coding in the 'act' method after the 'Greenfoot.stop();'' line. It would only be executed once -- at the time the puzzle was completed.
jeah you are saving some ram memory with that, but also you cant place anything after this line right ;) i couldnt see it anymore already turned my pc off yesterday, you know times running another way in europe than in the usa ;)
@Pointifix, I knew about the time thing. I sometimes miss things when posting about the same time as others. I thought I would inform you about the post, just in case you ran into that kind of problem.
If you looked at my latest update, you will see that I did indeed place stuff after it (and documented the code; and other small additions/changes). But, you are correct if you qualify it with 'for puzzle solving issues' because every thing after it has to deal with a solved puzzle.
A new version of this scenario was uploaded on Sat Mar 08 14:08:28 UTC 2014
Pieces are numbered. Code is documented. Saves your solutions in UserInfo storage. Be the one to find the most number of unique solutions. High score table to be added in near future.
@Pointifix, there are 5 Strings of 50 characters each. I can store 4 solutions into 1 of those Strings, making a total of 20 different (unique -- no mirroring or rotating) solutions. Look at the documented code of the 'Puzzle' class after the 'stop' statement.
A String is actually an array of characters; so, in essence, I am using an array. But, as you pointed out, UserInfo storage does not have the capability of storing an array of int values to this magnitude (not even to 12 -- the number of pieces in the puzzle).
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/7
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8
2014/3/8