3
Contributors
7
Replies
8
Views
4 Years
Discussion Span
Last Post by pyTony
Featured Replies
  • - Check if the board is full, meaning that all cells are occupied and not empty - Then make sure there aren't any winning patterns for 'x' -- use your checkAll('x') - Then make sure there aren't any winning patterns for 'o' -- use your checkAll('o') - If all the … Read More

  • It should be something like so, in psuedo code: bool isFull(board){ bool isFull = true; for i = 0 to board.length # 0 <= i <= 8 if board[i] != 'x' && board[i] != 'o' isFull = false; break; return isFull; } Read More

1
  • Check if the board is full, meaning that all cells are occupied and not empty
  • Then make sure there aren't any winning patterns for 'x' -- use your checkAll('x')
  • Then make sure there aren't any winning patterns for 'o' -- use your checkAll('o')
  • If all the above passed then it is a tie
0

I'm having trouble figuring out how to check if all squares are full, could I get some more help with that?

1

It should be something like so, in psuedo code:

bool isFull(board){
  bool isFull = true;
  for i = 0 to board.length   # 0 <= i <= 8
    if board[i] != 'x' && board[i] != 'o'
       isFull = false;
       break;

  return isFull;
}

Edited by firstPerson

0

i am getting an invalid syntax error for that first line
sorry i havent learned bool yet :/
i also cant find anything about 'bool' after googling it

Edited by SumTingWong59: additional info

0

back to square one, any other help would be very appreciated, all i need now is how to check if the board is full

0
def is_full(board):
    return all(p in tuple('xo') for p in board)

or

def is_full(board):
     return not ''.join(str(p) for p in board).strip('xo')

Edited by pyTony

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.