Failing daily test: testMoveLeftAndBack

I am failing this test and the error is “Piece should not have been move to the left!”.

from the name of the test I have expected that this might be a move left followed by move right, where as result the piece should be back to the initial position before the move left being performed. Actually I have tried this case and it works well.

Another scenario might be is that moving when reaching a border maybe or a place where a move is not possible, this is case is working as well.

So I am actually clueless about how to solve this issue, It would be nice if I can get some hints where should my focus be.

I cannot say anything about the contents of the test.
But what I would suggest is, if you finished your implementation, try to play the game, maybe you will see at one point, that at this position, the piece should not have been moved to the left. For example, when there is another piece on its left, or it reached the left border of the game board.

And check again your canAddPiece method. If you are really checking if every tile of the piece can be added at the destination, not only the rotation point.

I hope that helped, and if not, just visit the OH tomorrow and a tutor can help you debug.

1 Like

Have you written test cases for this situation?
If so, do they succeed on your implementation and the reference?

I have written unit tests which test that a piece cannot be placed in a corner where it cannot be placed in the first place, the test I worte are for all shapes.

Also I wrote some test to check that a piece cannot be placed where a coordinate collide with other one. those test I have wrote for few shapes.

However, the tests succeed using my implementation.

Yes sure the implementation take into consideration all every tile of the piece and not only the rotation point.

I tried to run the autoplayer and watched its behaviour but I didn’t notice any erroneous behaviour.

There is currently no custom test in tetris.tests in your repository.

You can add tests there to see if they are correct (they are checked against our reference implementations as in the URI project).

Above, you suspected that this test has something to do with moveLeft. Have you written a test for this function?

I was failing the same test although my game was working perfectly fine.
My fault was that my getPieceColumn and getPieceRow methods in the TetrisGameImplementation class were wrong. Probably you should look at those or the attributes which you use to return the row or column of the piece.

4 Likes

Yes I didn’t upload the test till now, will do ASAP. However, the problem was in the TetrisGame implementation as @Jonathan.Mueller suggested, apparently I have misread the specification therefore my implementation wasn’t correct.
Thanks for the support.

You were right, I failed the test for the same reason as yours Honestly, I did not expect that problem might be there. Thanks for pointing out :slight_smile: .