TicTacToe


The goal of CTicTacToe is to check if:
1. the move is legal
2. winner declared

Key data:
CBoard is an union for easier access to bits and check the value of the whole number.
The board is 3×3. total 18 bits, 9 bits for one player
e.g. maBoards[0] has bitset<9> to track one player.
All 8 winning patterns pre-calculated in maWinningPatterns[8]
check winner by bit AND & maBoards[] and maWinningPatterns[] equals to maWinningPatterns[]
for each move to be legal, maBoards[ePlayer].maBitsStatus[iIndex] has to be 0

Download: http://riowing.net/p/wp/game.cpp

Previous Post
Next Post
Comments are closed.