Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:tic-tac-toe [2015/05/21 19:17]
cs142ta created
cs-142:tic-tac-toe [2015/05/27 05:14] (current)
cs142ta take out break
Line 119: Line 119:
  string winner = "​CATS";​  string winner = "​CATS";​
  
 +        bool is_winner = false;
  // as long as there'​s no winner and total moves is less than 9  // as long as there'​s no winner and total moves is less than 9
- for (int turn = 0; turn < pow(BOARD_DIMENSION,​2);​ turn++)+ for (int turn = 0; turn < pow(BOARD_DIMENSION,​2) ​&& !is_winner; turn++)
  {  {
  // select users mark  // select users mark
Line 141: Line 142:
  
  // check if it's a win  // check if it's a win
- bool ​is_winner = mark_makes_three_in_a_row(board,​ current_players_mark,​ row, col);+         ​is_winner = mark_makes_three_in_a_row(board,​ current_players_mark,​ row, col);
  
  // if it is a win  // if it is a win
Line 148: Line 149:
  // assign a winner and break  // assign a winner and break
  winner = current_players_mark;​  winner = current_players_mark;​
- break; 
  }  }
  // otherwise  // otherwise
 + else
 + {
  // switch turns  // switch turns
- is_x_turn = !is_x_turn;+         ​is_x_turn = !is_x_turn; 
 + }
  }  }
  
cs-142/tic-tac-toe.txt · Last modified: 2015/05/27 05:14 by cs142ta
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0