Hi Roland,So this is a translation from a chess engine written in Pascal to FreeBasic?Looking at the code it seems short, elegant and readable.Is there any high level description of how the engine works in detail?After my own efforts I recognize the key elements and seems so well done.

Chess.bas is an original program. It has the function of a referee : it computes legal moves, evaluates game state... but isn't able to choose a move.

Engine.bas is, as you noticed, an adaptation of a Pascal program.

The moves evaluation is divided into two steps. First the moves are evaluated by a recursive function whose terminal value is given by a relative material balance. The function makes two things : 1° it attributes to each possible move a value ; 2° it returns the best value found.

Then the BestMove() function is called. It fills a new move list with moves that had obtained the previous best value. Then the second evaluation step begins. I let you read in the function body : there are some smart ideas.

One thing to notice, is that the legality of the moves isn't checked : that's a reason why the computer plays so fast. The king is considered as an ordinary piece with a higher value.

I made some important modifications in the german version of the engine. When I have time I will make the same modifications into the english version.

About KC Chess, I had a look into it. It seemed to me that it's a good student work, and probably a good program to learn principles of Pascal language, but I don't think you would learn much things about chess programming by studying it.

I downloaded your program and only had a brief play so far but wanted to say thanks and well done, it is most impressive especially with gui also - I can imagine how much effort has been involved.

The screenshot reminded me of playing Fritz 2 and I realised why on reading the read me! Integrating Ed Schroder's Rebel books is also an excellent feature - one I wish I could have done as developing a book manually has been a very time consuming error prone and not to say tedious occupation.

It will be great when you add UCI compatibility - it is wonderful to see your engine play against others and see how it matches up.

Very nice project. I downloaded it just to have a look and programmed white and black to automatic. One thing I noticed is that the program would not make moves unless the mouse was moving. If the mouse was still, the program would just sit there. I am running Windows 8.1.

Thanks Roland.I've tried a few games and let it run auto.Same on Win XP as vdecampo reported with 8.1

Professional project, I can only imagine the work you have done for this, with much head scratching and swearing I should think.Cheers.P.S.If you have to nudge the mouse or click it to let the game continue on auto then no harm whatsoever, it gives you a chance to watch the moves.

After I read Vince's message, I tried the "computer versus computer" mode, and I saw the problem. I don't know where it comes from. (I also noticed that the engine seems to play even faster than in previous versions.)

There still are things to do (piece animation, UCI protocol, amongst other things).

In anticipation of UCI implementation thought it might be fun to quickly play a game between Eschecs and my program. Haven't looked at the code in detail but from a cursory look Eschecs searches to max depth of 5 so it seemed fair for a fixed depth game at this search depth (ie sd=5).

I played 6 games as white and only managed to get 7 white queens plus a white rook,bishop and knight.

*If you recall i was able to beat your early engine by taking all its pieces for the loss of only one white pawn.

Your latest engine still blunders the odd piece when it shouldn't but generally that only happens once or twice a game. It still plays a bit weird at times. ie Sometimes it is unable to checkmate the lone white king when it has a queen and rook but overall it does give the impression that its playing 'proper chess' and im sure its quite capable of beating casual players if they are not careful.

The game didn't crash or play any illegal moves.

I did notice it was fond of bishop takes knight. ( A bishop is worth slightly more than a knight) so this minor error can be rectified by increasing the value of the bishop a tiny bit.

Overall im very impressed. Its much harder than most people realize to build a chess engine that doesn't get wiped off the board by a club level player.

TESLACOIL wrote:Sometimes it is unable to checkmate the lone white king when it has a queen and rook

Yes, that problem is well known by chess programmers, and isn't so easy to solve. I have heard of endgame tablebases, but I haven't found time to study it.

TESLACOIL wrote:but overall it does give the impression that its playing 'proper chess' and im sure its quite capable of beating casual players if they are not careful.

The game didn't crash or play any illegal moves.

I am glad of that. I could let the program as it is. Before I try to make a stronger engine (which is indeed the most interesting part of the project), I should improve the interface, and first of all animate pieces movement. I have just made it in a chessboard for Free Pascal, and it was some work. When I feel ready, I will make the same in FreeBASIC.

I also need time to study inter process communication and chess protocols. It would be good to separate the engine from the GUI.

Last edited by Roland Chastain on Mar 16, 2014 14:32, edited 1 time in total.

TESLACOIL wrote:Overall im very impressed. Its much harder than most people realize to build a chess engine that doesn't get wiped off the board by a club level player.

So very true, the hardest thing is to build a stable engine that doesn't crash or play illegal moves and knows all the rules properly. Given today's hardware most engines that can do this with even a very basic alpha beta search and simple evaluation function should be good enough to give the average club player a challenging game.