I'm curious as to why you wrote your own chess implementation - seems like this would have been much easier to implement with chessboard.js [1] and chess.js [2]. 1. https://chessboardjs.com/ 2. https://github.com/jhlywa/chess.js/blob/master/README.md
I was investigating whether AI can write a complete game of chess in one shot, I livestreamed that here[1] and the answer is no (conclusion: major rules are there, but buggy), but I was able to get it into a working state after many hours of back and forth.
The original implementation froze whenever a pawn got to the seventh rank, and allowed castling out of and through check (illegal), it was very buggy.
Iterating with the AI, I added tons of stuff like drag to move pieces, mobile support, and, yes, computer play. When that was finished (it is available at: https://taonexus.com/chess.html ) I had it make this blunder-free variant and it got it pretty fast.