I'm making a chess engine and I want to split the task of calculating all the different moves and positions to multiple cpu cores instead of just one but I can't get it to work. This is the code which is supposed to do it.
with concurrent.futures.ThreadPoolExecutor() as executor:
#allChessPieces is an array of every possible chess piece the AI can move in the current board position
for chessPiece in allChessPieces:
executor.submit(engine,chessPiece,chessBoard)
The engine-function calculates every possible move that can be made with the given piece in the given board position and how the opponent can respond to that move and how the AI can respond to that move and so on. It gives an value for each move it calculates and stores the move alongside with its value in an array.
I want to be able to do these calculation for different pieces at the same time using mulitple cpu cores but right now I'm seeing python using only 14% of my cpu which is only 1 core.