
State I am going to stuff the BitBoard class into an AI (minimax), and therefore tried to have a state that was easy to handle and pass around.

Self._state = bit_clear(self._state, PLAYERO) Self._state = bit_clear(self._state, PLAYERX) In particular the lines self._state = bit_clear(self._state, GAME_ON) Speed I thought doing bitwise operations would be the fastest way to tackle this game, but my code is still very slow. I am looking for feedback on two particular issues Speed is very important as I am going to build this into a bigger project running minimax or other heuristics over the code. 9 bits are kept for X and 9 bits are kept for O.The one in the middle is not really desired, but I had to keep it there to be able to feed the state into a dict to figure out which squares are available.The second and third bit will show who the winner is after the game is over.The first bit shows if the current board is active or not, e.g if you can play on it.To challenge myself, I wanted the entire game logic + board state to be deducible from a single 32 bit integer henceforth referred to as gamestate or simply state. For reference I used the following source, bit it not required to understand my post. While perhaps chess is the most natural candidate I wanted to start of with something simpler.

So I have been learning more about binary numbers lately, particularly
