Posted October 01, 2023 by Ultraman287
#AI #Reinforcement Learning #Chess
The first thing I wanted to do was to remove the manual implementation of individual phased / normal walk squares since it doesn't make sense for a piece to be able to move both phased and not.
For the actual implementation, as I've explained in the comments, it's essentially just casting rays in the directions and stopping as soon as a discrete collision happens
The next part was figuring out how I'm going to have the phased movement be saved then and for that I just made it so the numpy file that's getting saved for each custom piece will also have a number corresponding to whether it supports phased movement or not.
My god minor mistakes in a giant repository are beyond frustrating to deal with because the issue to solve is so tiny.
Basically, every piece that I was putting into the board would automate to have non-phased movement. That was an issue since I want my pieces to have been custom. I thought this was solved by putting that within the actual initialization of the piece however that wasn't the case since I forgot the other earlier solution I had worked on.
In that case, I had to deal with the issue of object references since my copies were just getting repeated in a list, any action that I did on any of the pieces always just happened on the last one that happened to be referenced in memory. To solve that I introduced the copy function for my game piece that would create an identical object with its own unique reference.
This turned out to be the source of the issue since I completely forgot to account for the fact that, I'd have to put the phased movement attribute into the new function as well. I think there might be a better way to make a new iteration where I copy over all the kwargs from the initialization of the object to make a more generalizable solution but that doesn't feel too necessary in this case.
However, the big thing with this update is that
THE GAME IS FINALLY END TO END PLAYABLE.
(Illegal moves are still allowed, as in, you can just move a random piece while you're in check and have your king get taken and lose but I thought that might be a fun experiment to see whether Reinforcement Learning's going to be able to encode that information automatically to sense danger.)