Skip to main content
deleted 104 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Your bool TicTacToe::check(char player) const is still completly hardcoded to have a dimension of 3x3. I think it's even worse, as in more hardcoded, than the previous one.

Your class has a constant mDim. Define your rows, columns and diagonals using that constant. The number of rows and collumns is determined by mDim. Also the length of each row, column and diagonal is determined by 'mDim'.

The same goes for bool checkCondition(const pairCondition& i, const std::array<int, 3>& a, char player). The 3 is hardcoded but should be governed by mDim.

Try making mDimmDim selectable in the constructor and play a standard 3x3 game of ticTic-tacTac-toeToe and a larger 4x4 game of ticTic-tacTac-toeToe-tuzTuz to see if you have have removed the hardcoded 3 everywhere.


If you want to go one step further you could remove the hardcoding of the board being a square and the board being 2 dimensional. Ever played 3D ticTic-tacTac-toeToe?

Your bool TicTacToe::check(char player) const is still completly hardcoded to have a dimension of 3x3. I think it's even worse, as in more hardcoded, than the previous one.

Your class has a constant mDim. Define your rows, columns and diagonals using that constant. The number of rows and collumns is determined by mDim. Also the length of each row, column and diagonal is determined by 'mDim'.

The same goes for bool checkCondition(const pairCondition& i, const std::array<int, 3>& a, char player). The 3 is hardcoded but should be governed by mDim.

Try making mDim selectable in the constructor and play a standard 3x3 game of tic-tac-toe and a larger 4x4 game of tic-tac-toe-tuz to see if you have have removed the hardcoded 3 everywhere.


If you want to go one step further you could remove the hardcoding of the board being a square and the board being 2 dimensional. Ever played 3D tic-tac-toe?

Your check() is still completly hardcoded to have a dimension of 3x3. I think it's even worse, as in more hardcoded, than the previous one.

Your class has a constant mDim. Define your rows, columns and diagonals using that constant. The number of rows and collumns is determined by mDim. Also the length of each row, column and diagonal is determined by 'mDim'.

The same goes for checkCondition(). The 3 is hardcoded but should be governed by mDim.

Try making mDim selectable in the constructor and play a standard 3x3 game of Tic-Tac-Toe and a larger 4x4 game of Tic-Tac-Toe-Tuz to see if you have have removed the hardcoded 3 everywhere.


If you want to go one step further you could remove the hardcoding of the board being a square and the board being 2 dimensional. Ever played 3D Tic-Tac-Toe?

Source Link

Your bool TicTacToe::check(char player) const is still completly hardcoded to have a dimension of 3x3. I think it's even worse, as in more hardcoded, than the previous one.

Your class has a constant mDim. Define your rows, columns and diagonals using that constant. The number of rows and collumns is determined by mDim. Also the length of each row, column and diagonal is determined by 'mDim'.

The same goes for bool checkCondition(const pairCondition& i, const std::array<int, 3>& a, char player). The 3 is hardcoded but should be governed by mDim.

Try making mDim selectable in the constructor and play a standard 3x3 game of tic-tac-toe and a larger 4x4 game of tic-tac-toe-tuz to see if you have have removed the hardcoded 3 everywhere.


If you want to go one step further you could remove the hardcoding of the board being a square and the board being 2 dimensional. Ever played 3D tic-tac-toe?