This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for 12-pce Rectangular Puzzle

Return to 12-pce Rectangular Puzzle

A new version of this scenario was uploaded on Fri Mar 07 03:28:08 UTC 2014
A new version of this scenario was uploaded on Fri Mar 07 03:36:52 UTC 2014
A new version of this scenario was uploaded on Fri Mar 07 15:08:03 UTC 2014
PointifixPointifix

2014/3/7

i werent able to complete the puzzle :) you kept your source code clean as alltimes, good to copy from ;)
A new version of this scenario was uploaded on Fri Mar 07 15:50:54 UTC 2014
A new version of this scenario was uploaded on Fri Mar 07 15:55:09 UTC 2014
Entity1037Entity1037

2014/3/7

Very professional!
danpostdanpost

2014/3/7

Thanks guys.
PointifixPointifix

2014/3/7

are there more solutions? or only one?
danpostdanpost

2014/3/7

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.
PointifixPointifix

2014/3/7

k without mirrors and rotations mhhmm, im trying something like the 20th time now, still didnt got a solution ;D
PointifixPointifix

2014/3/7

is there a goal detection?
danpostdanpost

2014/3/7

Right now, the scenario just stops when solved. So yes, but not very user friendly in that regard.
PointifixPointifix

2014/3/7

i dont mind ;)
danpostdanpost

2014/3/7

The Puzzle class 'act' method deals with that after checking for button presses. Check the code out.
PointifixPointifix

2014/3/7

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?
bournebourne

2014/3/7

Nice job, I like how the pieces seem to enlarge and shrink between the board and side.
danpostdanpost

2014/3/7

@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.
PointifixPointifix

2014/3/7

ah ok a resolution i never took yet, always used if ;)
danpostdanpost

2014/3/7

@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.
danpostdanpost

2014/3/7

@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.
PointifixPointifix

2014/3/7

jeah maybe ;)
danpostdanpost

2014/3/7

@Pointifix, I had posted again ... hope you saw it.
A new version of this scenario was uploaded on Sat Mar 08 06:09:14 UTC 2014
PointifixPointifix

2014/3/8

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 ;)
danpostdanpost

2014/3/8

@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
danpostdanpost

2014/3/8

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.
PointifixPointifix

2014/3/8

how do you save a solution in userinfo storage? theres no space for arrays?
danpostdanpost

2014/3/8

@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.
PointifixPointifix

2014/3/8

mhhmm ok thats a variant, but with an array it would be much easier ;)
danpostdanpost

2014/3/8

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).
PointifixPointifix

2014/3/8

by the way, whos sponsering the servers for all the scenarios and data? Univeristy of kent? or oracle?
danpostdanpost

2014/3/8

@Pointifix, as I am not a member of the Greenfoot team, I cannot rightly say. My guess is University of Kent.
PointifixPointifix

2014/3/8

i just think that must be a lot of data, all these images, sounds and code data