Nov 29, 2008

[Programming] Dependency on the static Mediocre-class

While going through the code I noticed many of the classes uses the static variables located in the Mediocre-class. It is not a good idea to use them directly like that, for the sake of encapsulation.

Examples of this is the Evaluation-class which uses evalHash and pawnHash that are located in the Mediocre-class.

So basically every class and method will get an extra argument where the used structure is passed instead.

[Programming] Interface finals

Somewhere in the very beginning of Mediocre I decided to make an interface called "Definitions" which would hold commonly used constants (like EN_PASSANT, W_KING etc.).

The use of an interface for this was something I thought was the "correct" thing to do at the time. However I have learned a lot about Java-programming since then and now I actually understand the real use for interfaces in Java (which in short is a kind of very basic blueprint for a class, which makes sure certain methods etc. exist).

However it seems I got a bit lucky while doing this. The interface is not "intended" to be used like this but it works very well.

The reason for this is that even though a real class with the same function could be created we would have to either use Definitions.W_KING to access the constants or extend the class, creating a subclass, which is not a good idea in the long wrong (a class can only extend one other class).

But since an interface is used it can be implemented instead, eliminating the need for the "Defintions."-part, while still making room for extending other classes if needed (and a class can implement many interfaces).

A problem would of course would be duplicate names (which can be avoided altogether with clever naming, but anyway) since a whole list of variable names gets taken in the Defintions-interface. However if this occurs, all that is needed is to use e.g. Defintions.W_KING again, defining which W_KING is meant.

In short, the definitions-solution I've used for two years now turned out to be a very good way to handle the constants. And I will stick to it.

[Other] Makeover and perhaps results eventually

I started to go through the code of Mediocre again and the first step is to get the (extremely) messy Board-class a bit more readable (and hopefully faster).

To achieve this I migrated the needed classes to a new project, the classes are Board, Move, Definitions, See and Zobrist. All used in some way when generating and making moves on the board. (although See is only used in one line of the Board-class, which i totally forgot what it did, I'll have to look into that)

Also I am extending the Perft-class to become a bit more functional when it comes to testing the moves on the board. Adding a main-method and support for automatically checking for correct values, as well as timing the operations.

A first step towards a total makeover of Mediocre, let's hope it lands somewhere good.

Nov 28, 2008

[Other] Links down (and up again)

So basically I let the blog die without notice, sorry about that. :) And apparently my hosting for the source and executables have also died sometime in the last couple of months.

I will get around to working on Mediocre soon enough. I just have to figure out what I want to do. I have been looking for online solutions where people can play against Mediocre and others using a simple applet, maybe that is something to start working with.

Anyways in the mean time I have put up the site on my University webspace with the not so beautiful address:

http://www.cs.umu.se/~c03jpn/mediocrechess/

(thank you George for making me aware of the dead links)