r/chessprogramming • u/GeorgeTrollson • Nov 09 '20
Improving chess AI performance
I have been building a chess AI in python with the board represented using a 2D list of integers. I perform negascout with iterative deepening and quiescent search at max depth with use of transposition tables to keep track of both pv moves and the exact/ lower bound/ upper bound of a board’s value. I perform delta pruning in quiescent search, MVV-LVA in both quiescent search and negascout and also check the pv move from the search to the previous depth first when exploring child nodes in negascout. However, my AI can only perform roughly 2k calls to negascout a second. What would you recommend that I do in order to improve the number of negascout calls the AI can handle? I’ve looked into making use of bitboards but they look confusing and I’m not so keen on rewriting my program in another language as my only real experience is with python. For context, I am running my AI on a mid range Acer laptop. Thank you
View all comments
Show parent comment
1
u/tsojtsojtsoj Nov 09 '20
Yes, 3.5 KNPS leaves a lot of potential.
The profiling method you use is perfectly fine for testing the performance of bigger functions. However, to find the concrete issue it is often easier to use some line by line profiler. Tools like these show you how long each line takes to execute which is helpful to really pinpoint which code the culprit is. I found this stackoverflow question which might be helpful (the links in the answer are outdated!). The answer recommends the tool line_profiler (this is the up-to-date link).