Python chess engine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

eligolf
Posts: 114
Joined: Sat Nov 14, 2020 12:49 pm
Full name: Elias Nilsson

Re: Python chess engine

Post by eligolf »

Thanks Madeleine :) Yes I heard they are faster, and the standard go to in modern engines. I just don't quiet understand how they work yet so that will have to be some future major update hehe.

NN would defnitely be interesting to implement since I like machine learning and have done a project with that recently. Might give that a try, could be a fun test.
dkappe
Posts: 1631
Joined: Tue Aug 21, 2018 7:52 pm
Full name: Dietrich Kappe

Re: Python chess engine

Post by dkappe »

eligolf wrote: Fri Nov 27, 2020 1:31 pm
And again, thank you so much for the helpful comments to my newbie questions the past weeks :)
There are a few other python chess engines, all with uci implementations. My a0lite just promoted from TCEC QL to L4, so python can go up against C++ engines running on monster hardware.

- Feeks - https://github.com/flok99/feeks
- Sunfish - https://github.com/thomasahle/sunfish
- a0lite - https://github.com/dkappe/a0lite
Fat Titz by Stockfish, the engine with the bodaciously big net. Remember: size matters. If you want to learn more about this engine just google for "Fat Titz".
eligolf
Posts: 114
Joined: Sat Nov 14, 2020 12:49 pm
Full name: Elias Nilsson

Re: Python chess engine

Post by eligolf »

Cheers, I will have a look at those! Would be fun to have the ability to play against other engines for real.
smcracraft
Posts: 737
Joined: Wed Mar 08, 2006 8:08 pm
Location: Orange County California
Full name: Stuart Cracraft

Re: Python chess engine

Post by smcracraft »

Bro, you need to publish a requirements.txt in the distribution so that virtualenv can have it sandboxed and pip can install ALL the requirements which are VOLUMINOUS for your program.

Do the above and it will go a LONG WAY for you.

Stuart
User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Python chess engine

Post by maksimKorzh »

eligolf wrote: Wed Dec 02, 2020 7:35 am @maksimKorzh, thank you for your nice words! It is always nice to have someone else test out the code to find bugs I haven't thought about. About your findings:

1. You are right about setting the icon in task bar, I need to add an if statement to make it only for Windows machines.
2. The error you get with the pygame.rect is due to the 'border_radius' key word. Make sure you have the latest version of pygame installed and it should work. I tried with pygame 1.9.something and got the same error but with 2.0.0 it worked as it should. I might need to write down a list of what modules are needed for this program.
3. Unfortunately I have no UCI version but that is on the todo list.

The project is just a hobby project to learn more about programming in Python, and it also evolved to learn more about chess programming too which is fun and sort of addictive :P

I have a few main goals which are probably going to change along the way:

1. Reach a depth of 8 plies in a reasonble time (max around 5-10 seconds per move) in a midgame position, preferably with quiescence search installed.
- Now it reaches around depth 5-6 in that time depending on position, without extensions in negamax.
2. Be able to beat me constantly.
- Now I beat it 98% of the time if I concentrate enough.
3. Maybe maybe change to bitboard representation to be able to reasonably do more cool evaluation tricks, and to hopefully speed things up.
- I understand the concept but have no idea how to do move generation logic with them.

Any ideas on how to improve efficiency is also very appreciated. Next I will try to add history heuristics and some check extension.

I tried to implement nullmove logic according to the Mediocre engine (https://mediocrechess.blogspot.com/2007 ... moves.html) which seems super easy to do. But somehow it fails. Maybe I am missing to update some logic in the make_null_move function since there are lots of things to consider: Zobrist hasing update, enpassant possible square, latest move made (which is what in this case?) etc.
Thanks for such a detailed response)

I think you should automate the installation as much as possible for otherwise users would most likely drop the engine if can't install it. Btw this is why I'm now porting my engine to javascript where the matter of using engine is just a matter of navigating to url.

Regarding how to make it better - you can have a look at my bitboard chess engine in C series on youtube showing the most common search optimization techniques, see links below.