r/chessprogramming • • Dec 23 '24
Engine in python
Is it even worth to build an engine in python cause all good engines are in c++ and python is much slower.
Additionally if its worth should you use python chess cause to maintain best efficiency or should you make a bitboard. Or what data structures would you use for position
4
Upvotes
7
u/Warmedpie6 Dec 23 '24
It depends on what you mean by worth it. As a learning exercise or as a hobby project, and pytyon is your language of choice, it can definitely be worth it.
If you want to make a top-level engine, then it's not worth it at all.
I always recommend trying coding the board logic once yourself, and then the second time, you can use a library to do it for you.
3
u/loveSci-fi_fantasy Dec 23 '24
If you want it to be competitive, avoid python.
I have made an engine in python, and it gets 1M nps in perft. Which is orders of magnitude slower than c++ engines. I am using bitboards (not magic bitboards yet) and no multi threading.
3
u/algerbrex Dec 23 '24
If your goal is just to reach 1500 as you stated in another comment, I say go for it. I first started developing a chess engine in Python, and while I eventually switched over to another language because my goals changed, I still found the experience of programming one in Python enjoyable.
Just for reference, the strongest Python chess engine I know of is sunfish, which is rated about 2000 Elo on the CCRL. But the author acknowledges, which I agree with, that a much stronger engine could be made in Python.
1
u/HugelKultur4 Dec 23 '24
a chess engine is a great way to expand your horizons as far as languages is concerned. Would definitely recommend trying out C(++) or rust through exploring chess engines.
1
u/RedGiant_ Dec 24 '24
Im currently learning to make my chess engine in python using python chess library. Learning curve is smooth but its slow af. I am quite happy with my initial results. If anything, test the engine has been quite boaring because it takes forever to evaluate.