What is the problem with my negamax implementation? I am currently attempting to make a basic chess engine in Python (Learning some basic concepts), but for some reason the engine is suicidal and does not detect the scholars mate. I am using python-chess for the board because I am lazy, but I think the issue is my implementation of negamax? I've read on chessprogramming wiki but still can't figure out the issue.

Here is the code on GitHub: https://github.com/AggressiveBee15/LousyEngine
I didn't run your code, but by just looking:


You should return the score when score &gt;= beta. This is consistent to Wikipedia:




Note when alpha >= beta, Wikipedia returns the score, not beta.


Your code doesn't detect checkmate? I don't see how your engine can report Scholar mate without detecting checkmate.
Minor issue. The condition should be &gt;= not &gt;, but that shouldn't change anything.
What outputs did you get from: print('New good move ...?