I thought I'd better show my chess program to you guys, it's called Fun Chess. It plays ok at the moment (1800 ELO) but I'm trying to get it up to master level - this might be difficult as this is a lot stronger than I am. You can change the board, pieces, background as in most programs. The default level is an average club player. There are also various coaching options available. Any feedback welcome.

Undo takes back one move (yours or the opponents). Just click it twice to remove the computers last move and your own. It offers a bit more flexibility to do it this way (ie if you want to change sides) rather than always taking back 2 half moves (or ply) at a time.

Not sure why 1.6 Ghz processor not enough. I play it on a small netbook with an atom processor and it seems to play reasonably well. Perhaps it depends on what else you have running. Can I ask why you say this - was it playing bad moves or were the graphics messed up?

My apologies then. I did have an issue where someone would play the program and complain that a move was very poor but then it turned out that they were doing video editing (or similar) in the background and the program didn't really have a chance to search very deep at all. As a compromise it always searches at least so many moves at a given depth (I think 2) and then displays that message before quitting the search. Hopefully it doesn't wait too long before playing. If it always shows that message and you're doing nothing else then I might change the set up.

Searching: I search moves to a given depth. I then extend that depth if there are still captures at the end of the search. Alpha beta pruning is used to cut down the size of the search tree. Ordering the moves using MVV/LVA ordering makes the alpha beta pruning more efficient. Killer moves (moves that were pretty good before) are also tried before anything else. Iterative deepening is then used to search deeper and deeper until the time runs out. For the first move the scores returned by the previous search dictate the order in which they are tried. I also use stand pat evaluations to decide whether it's worth even trying given exchanges. A small opening book provides some variation at the start of the game. Board evaluation covers most things including material, piece positioning and pawn structure.

I aim to include null moves and transposition tables in the next month and perhaps IID. Sadly I also need to fix a few bugs. The program still only plays like a moderately strong club player and in all honesty I was hoping to get it to master level by now. One thing I have learnt is that it's surprisingly difficult writing a decent chess program. I guess it will just be a work in progress for some considerable time to come.

Learning won't work simply because there are too many positions to learn - I did once write a learning OXO program which played well but obviously there are infinitely less positions to learn in OXO than in chess. Reasoning sounds like a good idea (that's how we play ourselves) but getting computers to think in the same way we do has never been achieved yet so doing this (and getting it to play chess) might be a fair challenge.

I played a game and promptly went down two pawns (at my peak I was 1804 UCSF rating), but managed an opposite bishops ending. This gave me an opportunity to test out your end game play and "drawn game" provisions. I pretty much sat my King in the center and moved my Bishop back and forth between two squares for about a hundred moves.

I *think* you algorithm avoided repeating a position 3 times, but am not certain, and that it also avoided the rule where there has to be a pawn advance in fifty moves, but it sure seemed to lose its sense of direction once I staked out a passive, defensive position. I think it had a won game, though there are a few challenges to opposite Bishops.

I believe the error you had is simply because it ran out space in the move array - I never play such long games and so I never met the bug. I'll fix it later tomorrow. If you try it again in a day or so and just paste in those moves then you can continue where you left off but it looks like a draw to me even though it's 2 pawns up. You did very well to get a draw (I usually loose against it these days).

I'll try to implement your suggestions but I'm not sure how to play a sound with out it playing. I'll have to look in those damn manuals

A work-around, if you can't find a way to change volume, is to record a short amount of silence and make that your first cue.

Why record silence? It's pretty easy to generate on-the-fly.

@pjt33 Agreed, if you know your way around with sounds. If he doesn't know how to change volume, generating on-the-fly might also be a bit of a lift. But maybe you know of a nifty way to do this? (I'd be writing zeroes to a SourceDataLine, I think.)

By the way, if the end of the existing Clip is silent, one could also move to just before the end of the clip before starting, via setFramePosition() or setMicrosecondPosition(), and prime the sound system that way. (Theoretical--I haven't actually done this yet, but it should work.)

@Mike: do you know that you only have to load and open the clip once, right? Replays are done by resetting to the start of the clip (using either of above methods) before using the start() method again. That will cue off more quickly than reloading the Clip from memory for each playback (something just about everyone does until the light-bulb goes off).http://docs.oracle.com/javase/tutorial/sound/playing.html

This is SO minor, compared to what already works in your program. I feel bad taking up so much space with this discussion.

BTW: have you seen the articles by Larry Kaufman on how the point values of pieces varies during the course of the game or depending upon piece match ups? He alludes to this knowledge in "The Chess Advantage in Black and White"--but I can't recall whether he cites the articles there. He has done computer analysis of games to test or verify point values used in evaluation of positions. Perhaps incorporating this knowledge would be the key to getting your program up to Master level, more so than adding plies or increasing processing speed.

Sound : is the issue to do with getting the sound code into place or just loading up a particular sound for the first time? From your solutions it looks like the former but the latter seems more obvious. I'll try a blank sound first as this is the easiest to fit in plus your other suggestions guys.

Piece values : the piece values change all the time. Bishops pairs count more, knights are better in blocked positions, the pawns are very dependant on overall structure. Each time I make a change I seem to make a little progress in certain situations but never enough to really leap forwards. It is gaining strength by approx 50 ELO points each month but maintaining this progress is getting harder now.

Settings : I'm trying to incorporate a memory of what settings each user has ie level, board appearance, coaching preferences and the state of the current game. At the moment I'm just saving everything against a users IP address but the user can supply a name - type in "I am fred" and it will load fred's settings and current game on any computer - not sure if this is even slightly intuitive though . When I've done this I'll do another release which will include the larger move array and whatever I can manage with the sounds.