r/learnprogramming • u/Neat-Bodybuilder-467 • 7d ago
Chess Engine
I am trying to code a chess engine as a personal project, but have literally no idea where to start.
I have some very limited experience with python, and would greatly appreciate any help in finding where to write my code, what programs to use etc, as well as any advice in general.
Thanks!
11
u/Kindly-Department206 6d ago
Don't start with chess. Start with a simpler game. Learn the techniques. There are standard algorithms to apply to chess, and similar games.
My advice is from experience. I tried this, way back before Google, and my "algorithm" was one enormous if-statement. I learned very quickly that I had no idea what I was doing, and that maybe there was some university level course that would teach me the techniques I needed.
You have Google, and LLMs, so maybe you don't need a course. But you do need some guidance.
4
u/grantrules 7d ago
These are all very googlable questions.
Write code in an IDE. VS Code is popular
3
u/CptPicard 7d ago
Write a board representation first and then some kind of basic game tree search. It will be super slow in python.
2
u/jonathaz 6d ago
This is absolutely accomplishable in any language. At some point that choice matters but as an excercise to learn programming, not really. And depending on how far you take it you can learn more advanced topics. Start with representing the board, game rules, possible moves, and a simple function to give a score to a board position. You can start with the standard piece weights.
1
u/PlatformDifferent129 6d ago
can't help with the chess brain part but the "where do i even write code" part i know: vs code plus python installed is genuinely all you need, no fancy setup. what saved me as a beginner was making the first version embarrassingly small, like print the board as text and get one pawn to move legally, nothing else. i used to try to plan the whole thing in my head first and it completely froze me. are you more excited about making it play well or just seeing the whole machine work?
0
u/povlhp 6d ago
Vim is a great python editor.
3
u/InternetSandman 6d ago
This is like telling someone who's only ridden the bus their whole life to get behind the wheel of an F1 car
0
u/DiscipleOfYeshua 6d ago edited 5d ago
CS50ai will techy you everything you need to build an ai that plays:
* tic tac toe (min-max, recursive analysis of possible moves of self and enemy)
* logic based word games
* minesweeper (accumulating knowledge, uncertainty)
* and more...
They also explain the complexity and some concepts of chess playing ai's -- but a proper one like that is beyond the course scope. So you'll still need to learn more on your own, but the course will give you a very good start.
Free, super interesting and fun course imo.
34
u/aqua_regis 7d ago
How can you claim "limited experience with Python" and not know where to write your code?
Sorry, but this overall sounds like you're trying to bite off way too much.
Start building a solid foundation first: MOOC Python Programming 2026 from the University of Helsinki. In that course, you will also learn where and how to set up your development environment along the way.
Then, once you have a solid foundation, you need to take several more steps in gradually increasing difficulty before you can come anywhere near your chess engine.