feeks

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
flok

feeks

Post by flok » Fri Dec 29, 2017 11:57 am

Hi,

I wrote a chess program in python.
Move-gen by the python-chess library.
It speaks UCI.

https://github.com/flok99/feeks

flok

Re: feeks

Post by flok » Fri Dec 29, 2017 2:47 pm

[pgn][Event "Computer Chess Game"]
[Site "lenovo"]
[Date "2017.12.29"]
[Round "-"]
[White "Feeks"]
[Black "GNU Chess"]
[Result "0-1"]
[TimeControl "300+12"]
[Annotator "1. +0.02 1... +0.12"]

1. Na3 {+0.02/8} Nc6 {+0.12/14 26} 2. Nf3 {+0.01/9 19} e5 {+0.25/14 0.1} 3.
Nxe5 {+0.60/8 19} Nxe5 {+1.89/12 6} 4. Rb1 {-1.03/8 10} Nf6 {+2.58/13 16}
5. Rg1 {-0.28/9 15} d5 {+3.11/12 26} 6. Nb5 {-0.32/8 12} a6 {+3.83/13 26}
7. Ra1 {-0.32/9 19} axb5 {+6.49/12 14} 8. f4 {-3.29/7 18} Nc4 {+7.12/13 28}
9. e4 {+2.82/7 18} Nxe4 {+9.28/13 21} 10. Qe2 {-3.99/7 12} Bc5
{+10.63/13 38} 11. Qxe4+ {+5.43/8 18} dxe4 {+18.26/10 23} 12. Be2
{-12.67/7 17} Bxg1 {+21.33/11 7} 13. d3 {-19.37/7 17} Qh4+ {+99.87/10 19}
14. g3 {-14.40/7 17} Qxh2 {+99.89/15 15} 15. dxc4 {-20.88/5 14} Bg4
{+99.91/49 2.9} 16. Bxg4 {-21.42/7 16} Qf2+ {+99.93/48 0.1} 17. Kd1
{-100.00/10 11} Rd8+ {+99.95/49 7} 18. Bd2 {-100.00/11 14} Qxd2#
{+99.99/49 19}
{Xboard adjudication: Checkmate} 0-1[/pgn]

lukasmonk
Posts: 44
Joined: Sun Feb 07, 2010 6:35 pm
Location: Spain
Contact:

Re: feeks

Post by lukasmonk » Fri Dec 29, 2017 3:51 pm

You probably already know, but just in case, to make the use of your program by users (especially Windows users) more user-friendly, you could create executables very easily, using pyinstaller and running

Code: Select all

pyinstaller main.py -F

flok

Re: feeks

Post by flok » Sat Dec 30, 2017 9:12 pm

I didn't
thanks!

User avatar
Guenther
Posts: 3011
Joined: Wed Oct 01, 2008 4:33 am
Location: Regensburg, Germany
Full name: Guenther Simon
Contact:

Re: feeks

Post by Guenther » Sun Dec 31, 2017 9:24 am

Looks more like a (nearly) random mover? (similar to POS)

Guenther
Current foe list count : [91]
http://rwbc-chess.de/chronology.htm

flok

Re: feeks

Post by flok » Sun Dec 31, 2017 1:29 pm

Not at all!
Fully a/b with psq, material, lmr, null move, tt

User avatar
Guenther
Posts: 3011
Joined: Wed Oct 01, 2008 4:33 am
Location: Regensburg, Germany
Full name: Guenther Simon
Contact:

Re: feeks

Post by Guenther » Sun Dec 31, 2017 1:43 pm

flok wrote:Not at all!
Fully a/b with psq, material, lmr, null move, tt
Then it must have immense bugs. In your game example it blunders permanently pieces here and there?
Current foe list count : [91]
http://rwbc-chess.de/chronology.htm

flok

Re: feeks

Post by flok » Sun Dec 31, 2017 2:01 pm

The problem may be that it reaches only depth 5 in 3.7 seconds.

Sven
Posts: 3822
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: feeks

Post by Sven » Mon Jan 01, 2018 6:14 pm

The piece-square table implementation needs a fix. The table init code lists values for ranks 8 down to 1 but the psq() function uses it the other way round. So you might want to write this:

Code: Select all

if piece.color == chess.BLACK:
    table_pos = pos

    val -= psq_table[symbol][table_pos]

else:
    pos_y = pos / 8
    pos_x = pos % 8

    table_pos = (7 - pos_y) * 8 + pos_x

    val += psq_table[symbol][table_pos]
instead.

Next thing is I'm not sure whether en passant is handled correctly, both in your search (e.g. pc_to_list(), blind()) and in the python chess library. The latter is only a vague suspicion: when trying to fiddle around a bit with your engine I added a LegalCapturesGenerator class to the python chess library (based on the already existing function generate_legal_captures()) and used it in your qsearch - mainly by adding an is_qs flag to pc_to_list() - to see whether that would make things faster but then I noticed a reproducible crash after 1.d4 Nf6 2.d5 e5, and adding test code that prints some message if the current board allows a legal en passant capture crashed as well so there might be something wrong - could even be my fault of course.

Have you checked the move generator code with perft? Or has someone else already done that for the python chess library?

Also the engine is *really* slow. I have not found out yet whether that is caused by the python chess library or by your search code.

flok

Re: feeks

Post by flok » Mon Jan 01, 2018 6:56 pm

Sven wrote:The piece-square table implementation needs a fix. The table init code lists values for ranks 8 down to 1 but the psq() function uses it the other way round.
Oh indeed! Oops!
Some code was translated from Embla and I made some mistakes here and there. Earlier today there I found a sign-problem in null move.
Next thing is I'm not sure whether en passant is handled correctly, both in your search (e.g. pc_to_list(), blind()) and in the python chess library. The latter is only a vague suspicion: when trying to fiddle around a bit with your engine I added a LegalCapturesGenerator class to the python chess library (based on the already existing function generate_legal_captures()) and used it in your qsearch - mainly by adding an is_qs flag to pc_to_list() - to see whether that would make things faster but then I noticed a reproducible crash after 1.d4 Nf6 2.d5 e5, and adding test code that prints some message if the current board allows a legal en passant capture crashed as well so there might be something wrong - could even be my fault of course.

Have you checked the move generator code with perft? Or has someone else already done that for the python chess library?
I have not verified it no, I expected it to be correct. I'll add a perft.
Also the engine is *really* slow. I have not found out yet whether that is caused by the python chess library or by your search code.
Well node count is low so I think it must be in move-gen.

Post Reply