Saturday, 24 March 2007

It works!

I finally gave in and decided to write a divide() function to count the number of positions per move and comparing it with the results of Sharper. My other lazy attempts were fruitless. So after writing the divide method, downloading Sharper and seeing how simple it is to use I started debugging...

It seemed castling was the culprit yet again. Let's start with the basic rules of castling: A side may castle if the king has not moved; the rook has not moved; there are no blocking pieces and the king does not move through check or is not in check. Do you spot the bug? Aren't I missing something... Yes, you actually need to HAVE a rook in the first place!! I never canceled the castling bit if the opponents captured a player's rook. The result was a weird castling move without the rook. Funny right? I don't think so! :-)

Well, the move generation, making and taking back of moves now works beautifully. It is not a pure pseudo-legal move generator as it will not generate castling moves if the king moves through check or is in check currently. This does cause a slight drop in speed - but I hope that it will pay off later.

At last, I can start with the alpha-beta search.

No comments: