Curious Bug

I was playing the Chess game in Clubhouse Games on the Nintendo DS last night, and I’ve discovered a bug that can occur in a very unusual situation. Normally, the game quite rightly allows you to only make legal moves. For example, when in check, the only legal moves are those moves which get you out of check, either by (a) capturing the attacking piece, (b) blocking the attack or (c) moving the king in such a way that he is no longer in check.

However, it looks like the programmers of Clubhouse Games, when writing support for the en passant rule, gave en passant moves more importance than they should have, making them always valid moves (even when they shouldn’t be). Consider the scenario below:

Chessboard showing how to break Clubhouse Games with an en passant move

Black moves his pawn two squares forward, putting white’s king in check through his bishop. At this point, the only valid moves for white should involve moving the king out of check. However, Clubhouse Games will also accept the white pawn capturing the black pawn en passant as valid.

Of course, being a bit of a geek, I felt compelled to do this (illegal) move, just to see how the game engine handled it. The result was that I was told that I had lost, and then the whole game crashed and locked up.

Sloppy coding there, guys, which could easily have been avoided by putting the valid move check after the special moves. I wonder if similar problems affect castling…

1 comment

  1. Gareth Gareth says:

    Yeah, they probably hadn’t written unit tests for that *ahem*.

Reply here

Your email address will not be published. Required fields are marked *

Reply on your own site

Reply by email

I'd love to hear what you think. Send an email to b1218@danq.me; be sure to let me know if you're happy for your comment to appear on the Web!