Tuesday, November 30, 2004

Integration sucks!

Well I got JavaChess working easily. There is just one problem...not only is it bad it is buggy! At first I couldn't play a complete game because an array kept going out of bounds. I fixed that and now it is trying to make illegal moves when mate is inevitable! I am thinking seriously about rewriting it using TDD. I will try to fix this bug, but the code is pretty hard to follow, not that it written poorly, it just wasn't written by me and it has NO tests!!!

Wednesday, November 24, 2004

Will I ever make any progress?

I feel like John Kerry! I can't make up my mind (sorry for those Kerryites out there, but I just couldn't help myself) I have scratched the idea of incorporating Crafty. It would be ugly, messy code and what would be the point? Jose already does this. I found a great article on chess programming. The last series has a link to the author's code, and it is written in Java! I have downloaded it and put the javachess package in my project. It compiles, but doesn't run. His code isn't written to be integrated, but that's a challenge I like! We shall see how long it takes to get working code.

Have a happy Thanksgiving! Remember to be thankful!

Thursday, November 18, 2004

Stumbled on Jose's Secret

Jose doesn't actually play chess! It uses crafty (a freeware chess engine that is the best free chess engine out there judging by fifth place showing in the WCCC) The interface to crafty isn't ideal, but it shouldn't be too hard. When I discovered this I had halved to time it took for me to analyze moves, but it was easily becoming apparent that I didn't know the least bit about how to actually do it. When I went looking in the source for Jose I couldn't find any logic, but I stumbled on a comment about converting representations from Jose to Crafty. A few minutes later and Google had found me the link that I needed. Then I simply found the crafty.exe and it was confirmed. So now I think I will ditch my plans for improving my pathetic chess engine. I was further convinced of my move when I stumbled on this page about chess tree searching algorithms. I hardly understand what they are talking about! Interfacing with Crafty it is!!!

Friday, November 12, 2004

Discouraged

I stumbled on http://sourceforge.net/ yesterday and found Jose. It is a Java chess program that loads PGN, has an extensive opening book and plays better than the free version of ChessBase, ChessBase Light. Its only flaw is poor time control. It beats the pants off of me, unless I manage to hold it off and let it use all its time up. The source is available and contains over 400 files and over 3 meg of source! This was all done by one guy!!! Boy do I feel stupid. When you run this thing you can see it work and it does thousands of Nodes (basically a move in a move tree) a second! My stupid program takes 2 seconds for roughly 400 moves! Order of magnitude difference. Mine also seems to get slower because If I look 3 ply ahead (2 for moves for the computer and one for human) it takes over a minute!!! I feel completely discouraged, but I must remember that I have only been working on this two weeks and only have 11 files and 65Kb of source. I will keep on plugging, although I don't feel overly motivated...

Wednesday, November 10, 2004

Decent chess is hard

It took a while, but I finally got it playing "decent." It desperately needs an opening book, but if you don't take advantage of its opening stupidity then it plays OK. It has beaten me a couple of times, even though it only looks one move ahead (this shows you how bad my game is of late). It is pretty slow. My code isn't effecient at all, but each move only take 1-2 seconds. I am not going to call it a success yet. I want to see if I can get it looking 2-3 moves ahaed and do some pruning (not look at move combos that are obviously bad). Then I need a simple opening book, the start of the game really kills its chances.

I have 2125 LOC and 1171 of it test code. One interesting note is that only 117 lines of the code are for the ChessPlayer.

Monday, November 8, 2004

Smooth sailing

Well I haven't got much done. Having two small kids can lead to a busy life! I got the program playing random chess moves late last week (I wanted to post it, but blogger wasn't letting me) I then added some intelligence. If you give it a mate move it will take it and win! It will always takes a piece, even if it is defended (yes it will trade a queen for a pawn). This is caused by the fact that it only looks at the result after the computer moves, not the response. It plays pretty badly, but it plays!

I have 1871 LOCs and 1035 of it tests (divided between testing the ChessBoard and the ChessPlayer) I have been closing my mind to ideas such as efficiency of memory usage and processor utilization, but that hasn't been a factor so why worry now! Let the chips fall where they may. Next is to have the ChessPlayer play out my moves, so he doesn't do stupid trades. Then I need to give it some algorithm about space (at least controlling the center and activating pieces).

This is going to easy...there must be a hidden troll under the bridge.

Thursday, November 4, 2004

Stalemate was easy, but code duplication is a problem

Well implementing stalemate wound up being an easy task. It did uncover some interesting bugs that had been lingering around without detection. The test suite (44 tests strong) is doing its job magnificently! Lines of code is at 1163 with 637 of it test. All I have left to handle is three repeated positions and 50 moves without a pawn move or a piece captured. Then on to the hard part ;-) Remember my goal is to have this thing play decent chess (able to give me a game...not that hard these days ;-)

I guess I should say something about the election. Howard Fineman has an intelligent post mortem. The thoughts I take away from the election are simple: the news coverage was pathetic and this country is definitely of two minds.

The news coverage was bad because of their fear of predicting it wrong. Doesn't prediction always have a chance of being wrong? Funny thing is even Kerry admitted defeat before ANY news network had predicted Bush the winner. The closest were FOX and NBS with Bush at 269 electoral votes! Give me a break, it was over when Bush has a 140k lead in Ohio and the prediction of provisional ballots was at most 150k and Bushes lead in Nevada was ~3% with 99% of the vote in! Kerry new it, why couldn't any of the wimps that supposedly give us news tell us that plainly?

The second thought is about our country being of two minds. It isn't really political, meaning republican v Democrat (they simply change their platforms to meet the opinions of the masses). Gone are the days that the parties stand for anything. The two minds in America are secular and religious. The vast majority of urban population is secular and votes against anything religious. The vast majority of the rural population is religious and votes against anything secular. The parties have simply aligned themselves towards that. I think this issue is HUGE and will shape our future. I personally do not want a secular country, but I only get one vote ;-)

Tuesday, November 2, 2004

Checkmate done, but not much else

Well I finally solved all checkmates that I could think up. The weekend had me too busy to get much else done. So not much else got done. I now have 956 LOC of which 534 is test code for 38 tests. My next test is stalemate. This is tricky because I currently don't have any way of determining available moves for a piece. This will cause me to rewrite more code, but in the end I still would have done it the way I did it. Coding is all about learning, not writing code.