Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


UCI based chess Engine : Some questions.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 ashish123   Members   -  Reputation: 166

Like
0Likes
Like

Posted 31 May 2013 - 09:35 AM

I have coded a chess engine in C# which has no sophisticated features.

I have just done with mate detection and some crude static evaluation.

I am trying to make it UCI compatible, but then I am facing a question as to why the protocol returns the list of moves rather than the fen of the new position.

 

I mean the list of moves will take more time to execute and the space required is also more than equivalent FEN string.

Can any one help me with this?

 

 

 



Sponsor:

#2 Paradigm Shifter   Crossbones+   -  Reputation: 5412

Like
0Likes
Like

Posted 31 May 2013 - 10:42 AM

Presumably so it can tell if the same position comes up 3 times for a draw?


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 Álvaro   Crossbones+   -  Reputation: 13684

Like
0Likes
Like

Posted 31 May 2013 - 12:05 PM

First of all, the protocol allows both possibilities. What Paradigm Shifter says is true, but after an irreversible move (i.e., a pawn move or a capture) is played, the GUI could send the FEN for the position after the last such move and then the list of moves from that point. However, many GUIs choose to send the whole list of moves every time. Presumably this is done for simplicity. Although it might be suboptimal, it's not a problem in practice.



#4 ashish123   Members   -  Reputation: 166

Like
0Likes
Like

Posted 31 May 2013 - 01:52 PM

Hi all, Thanks for replying.

 

I faced this question as I programmed by Engine to setup board via FEN and not by move input.

I don't really keep track of game specs like castling and enpassant squares on move by move basis, but rather break the fen and adjust all parameters accordingly.

 

I am using Arena as GUI. Is there any setting where in I can just tweak it to send me the FEN instead of moves, but then again I wouldn't be able to keep track of 3-repetition draws.

 

If I go with the move approach, then I have to convert the physical move to logical 64 bit-bit-board move, adjust all the flags and so on.

So is this worth or is there anything else which I am missing.



#5 Álvaro   Crossbones+   -  Reputation: 13684

Like
0Likes
Like

Posted 31 May 2013 - 02:00 PM

Converting the move in algebraic notation to whatever data structure you use for moves shouldn't be too hard and you should definitely do it. You should also be able to keep track of castling, the en-passant square and how many moves have happened since the last irreversible move, because otherwise you can't implement the rules of the game correctly.



#6 ashish123   Members   -  Reputation: 166

Like
0Likes
Like

Posted 01 June 2013 - 11:12 AM

Hi alvaro, thanks for replying.

I implemented the move logic without considering 3 move repetitions which is going to be my next priority.

 

Here is a game that it played at maxDepth 5 without any sophistication not even killers or anything of that sort, plain alpha beta with very crude static evaluation.

it took about 15 secs to make a move on an average.

 

Here is the first game where it played with white.
1. d4 e6 2. e4 Nc6 3. Nc3 Bb4 4. Nf3 Nf6 5. e5 Ne4 6. Bd2 Nxd2 7. Qxd2 O-O
8. Bb5 d5 9. Bxc6 bxc6 10. O-O-O Bb7 11. Rhe1 a5 12. g4 f6 13. g5 fxe5 14.
Nxe5 Bd6 15. a3 g6 16. f4 a4 17. h3 Qe7 18. h4 Qg7 19. Qe3 Rfe8 20. Ng4 Kf8
21. Kb1 Re7 22. Qf2 Qh8 23. Qf3 Qg7 24. Qf2 Qh8 25. Qf3 Qg7 26. Qf2 {3-fold
repetition} 1/2-1/2
 
Here is the second game, playing with black.
 
1. g3 d5 2. Nf3 e6 3. Nc3 d4 4. Nb5 Nc6 5. e3 e5 6. exd4 exd4 7. c3 Bg4 8.
Qe2+ Be7 9. Nbxd4 Nxd4 10. cxd4 c6 11. Bg2 Bxf3 12. Bxf3 Qxd4 13. Qe3 O-O-O
14. Qxd4 Rxd4 15. h4 Nf6 16. b3 Rhd8 17. a4 Bb4 18. Ra2 Rd3 19. Bd1 Ne4 20.
Bg4+ Kb8 21. Bf5 Re8 22. O-O Bc5 23. Kg2 Rxb3 24. Bxh7 g6 25. Re1 Bxf2 26.
Rxe4 Rxe4 27. Kxf2 Rd3 28. Bg8 f5 29. Bh7 Rc4 30. Ra1 Rg4 31. h5 Rgxg3 32.
hxg6 Rg4 33. Ke2 Rd5 34. a5 Re5+ 35. Kf3 Rd5 36. Bg8 Rd6 37. Bf7 a6 38. Ra3
Rg1 39. Rc3 Rd8 40. d3 Rf1+ 41. Kg2 Re1 42. Kf2 Rh1 43. Bf4+ Ka8 44. g7 Rh4
45. Bc7 Rc8 46. g8=Q Rh2+ 47. Bxh2 b6 48. Qxc8 {Arena Adjudication. Illegal
move!} 1-0
 

There was a time when I actually thought that my program was pressing the game, but then as it is clear from the game, I have messed up with some move making issues which as of now I would be checking.

 

 



#7 Álvaro   Crossbones+   -  Reputation: 13684

Like
0Likes
Like

Posted 01 June 2013 - 03:03 PM

Look up "perft". It's the best way to find bugs in your move generation code and in your functions to make and undo moves.



#8 ashish123   Members   -  Reputation: 166

Like
0Likes
Like

Posted 02 June 2013 - 01:41 AM

Thanks for replying.

Can you comment on the speed of  the engine when it take max 30 secs to play a move at 5 plys and further 5 plies at QSearch(Without MVV/LVA or any sorting).

I asked you this as I would like to know if I don't have anything terribly wrong going on.

I ran perft suite as my unit test suite, had no findings.

I think I have messed up some where in make moves that come from GUI through UCI protocol. May be its missing some checks and other feature.

I would check on those by printing some display boards. 



#9 Álvaro   Crossbones+   -  Reputation: 13684

Like
0Likes
Like

Posted 02 June 2013 - 09:42 AM

30 seconds for depth 5 is absurdly slow these days, but I don't see much point in looking at the performance before you have implemented some very basic improvements. MVV/LVA in quiescence search is particularly critical.

 

How many nodes per second is your engine searching? Some people count calls to make_move, some people count calls to the recursive search functions; either one will do.



#10 ashish123   Members   -  Reputation: 166

Like
0Likes
Like

Posted 03 June 2013 - 12:17 PM

Thanks for the reply.
 
I setup this position r1bqkb1r/1p1p1ppp/p1n1p1n1/4P3/2B5/2N2N2/PP3PPP/R1BQR1K1 b kq - 0 9
 
In the first round, I didnot search in QSearch as the condition ply>=maxPly would fail and it wouldn't proceed with generation of Capture moves.
 
In the second round I added Qsearch with addition of 5 plys to search. So if at depth 5 it went to QSearch then it would search in Qsearch for 5+5 = 10 plys.
 
and got the following results on the first day and I also noted that my machine (Dell Studio Laptop was heated up pretty much).
 
Without QSearch.
Depth Nodes Time(msecs) kNodes/Sec
1 36 131 0.27
2 1757 160 10.98
3 7689 336 22.88
4 136953 2743 49.92
5 604808 17768 34.039
6 11339038 207256 54.71
 
With QSearch
Depth Nodes Time(msecs) kNodes/Sec
1 1087 239 4.54
2 13289 543 24.47
3 103435 2864 36.11
4 1313863 28137 46.49
5 7980765 175669 45.43
6 57394529 1266073 45.33
 
 
 
 
Here are the results after second day when laptop didn't heat up much.
Without QSearch.
Depth Nodes Time(msecs) kNodes/Sec
1 36 16 2.25
2 1757 19 92.47
3 7689 37 207.81
4 136953 288 475.53
5 604808 1742 347.19
 
With QSearch
Depth Nodes Time(msecs) kNodes/Sec
1 1087 17 63.94
2 13289 43 309.04
3 103435 242 427.41
4 1313863 2715 483.92
5 7980765 17249 462.67
 

I think this is a hardware + programming efficiency issue.

Please comment as to how can I improvise this.


Edited by ashish123, 03 June 2013 - 12:23 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS