Eschecs FreeBASIC (UCI chess GUI)

User projects written in or related to FreeBASIC.
Post Reply
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

Hello ! Here is the new version of Eschecs.
Last edited by Roland Chastain on Feb 07, 2014 5:48, edited 2 times in total.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Eschecs

Post by BasicCoder2 »

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.

How does it compare with this pascal program?
http://www.csbruce.com/~csbruce/chess/
http://www.csbruce.com/~csbruce/chess/report.html

Your translation seems to be very well done and is appreciated by a myself, a monolingual English speaking person.
I am unable to read Pascal let alone German or French :(

John
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

Hi John !

I am glad that you appreciate my work.

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.
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

Hello gentlemen !

Here is Eschecs 0.8.8.

Image
Last edited by Roland Chastain on Feb 09, 2014 17:02, edited 4 times in total.
SamSam
Posts: 20
Joined: Jan 19, 2014 15:43
Location: France

Re: Eschecs

Post by SamSam »

Hello everyone,

Wow, congratulation Mr Chastain, your game looks truly nice ! I am amazed. :D (en Français: je suis baba !)

Have a nice day,
SamSam
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

SamSam wrote:Wow, congratulation Mr Chastain, your game looks truly nice ! I am amazed. :D (en Français: je suis baba !)
Thank you ! I have been working on that project for two years.

There still are things to do (piece animation, UCI protocol, amongst other things).
FB_Numpty
Posts: 33
Joined: Jan 28, 2014 19:22

Re: Eschecs

Post by FB_Numpty »

Hi Roland

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.

I will enjoy using - thanks!
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: Eschecs

Post by vdecampo »

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.

Regards,
-Vince
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Eschecs

Post by dodicat »

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.
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

@FB_Numpty, vdecampo, dodicat

Thank you for your compliments and for your observations.

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.)
FB_Numpty
Posts: 33
Joined: Jan 28, 2014 19:22

Re: Eschecs

Post by FB_Numpty »

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).

Here is the pgn:
[Event "Computer chess game"]
[Site "Home-PC"]
[Date "2014.02.14"]
[Round "?"]
[White "Eschecs"]
[Black "Numpty DD8"]
[Result "0-1"]
[ECO "B19"]
[Opening "Caro-Kann"]
[Time "20:23:49"]
[Variation "Classical, 7.Nf3 Nf6 8.Ne5"]
[Termination "normal"]
[PlyCount "44"]
[WhiteType "human"]
[BlackType "program"]

1. e4 c6 2. d4 d5 3. Nd2 dxe4 4. Nxe4 Bf5 5. Ng3 Bg6 6. h4 h6 7. Nf3 Nf6 8.
Ne5 Bh7 9. Bc4 e6 {(e7e6) -0.92/5 1} 10. Qe2 Qxd4 {(d8d4) +0.48/5 4} 11. c3
Qd6 {(d4d6) +0.57/5 0} 12. Bf4 Qe7 {(d6e7) +0.33/5 2} 13. Rd1 Nd5 {(f6d5)
+0.71/5 2} 14. Bxd5 cxd5 {(c6d5) +0.81/5 0} 15. Qb5+ Kd8 {(e8d8) +0.71/5 0}
16. Qa5+ b6 {(b7b6) +1.01/5 0} 17. Qb5 Qf6 {(e7f6) +1.26/5 3} 18. Nh5 Qf5
{(f6f5) +1.09/5 0} 19. g4 Qe4+ {(f5e4) +0.84/5 0} 20. Kd2 Qc2+ {(e4c2)
+1.46/5 1} 21. Ke3 Bc5+ {(f8c5) +6.07/5 1} 22. Kf3 Qxf2# 0-1
Numpty might have won the test game but there is no competition in the visual department!
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

FB_Numpty wrote:In anticipation of UCI implementation thought it might be fun to quickly play a game between Eschecs and my program.
Interesting ! Thank you for the PGN : I keep a copy of it and will view the game in WinBoard.
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: Eschecs

Post by TESLACOIL »

Roland , im really impressed your hard work has paid off

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.
Roland Chastain
Posts: 1002
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs

Post by Roland Chastain »

Hello TESLACOIL ! Thank you for your detailed report.
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.
FB_Numpty
Posts: 33
Joined: Jan 28, 2014 19:22

Re: Eschecs

Post by FB_Numpty »

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.
Post Reply