for(inti=0; i<3; i++) {booleanh = board[i][0].equals(board[i][1]) && board[i][0].equals(board[i][2]);booleanv = board[0][i].equals(board[1][i]) && board[0][i].equals(board[2][i]);// if H or V is true, we have a row/column with the same chars - that means either a winner, or they are all empty}

etc etc etc

Adding a check for diagonal is simple, just like adding the check that it's not an empty line.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

As you can see, you mixed 'visuals' and 'logic' and it is going to be extremely annoying to code with all these strings.

Why don't you make board an int[][] and make the empty cells 0, and the players: 1 & 2

Suddenly your code would become a lot more readable:

1 2 3 4 5

for(inti=0; i<3; i++) {booleanh = board[i][0]==board[i][1] && board[i][0]==board[i][2];booleanv = board[0][i]==board[1][i] && board[0][i]==board[2][i];// if H or V is true, we have a row/column with the same ints - that means either a winner, or they are all zero}

I know how my code works though, but I do need to optimize in future if I want to get anywhere. I'll see if I can take that win check code in. Thanks.

Also, I understand that boolean check if iterating through each cell on the board, but how do we determine who has the pieces there? This is very confusing for me, sorry I might need some extra explanation if you're willing to help.

~Shazer2

"When you want to be successful as bad as you want to breathe, then you will be successful." - Eric Thomas

That all the cells are filled, doesn't mean there is a winner, it can be a tie. In the same way, you can win when there are less than 9 cells filled, so you have to call you checkWin( ) method after every turn, not after 9 turns.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

That's true, Riven. I'm having a problem, I dropped in my win check after each turn and now when I do check the win (place the final mark in a row of 3) it checks the win, before it's placed (redraw of board).

So I am checking the win correctly but it is checking the win before the final piece is drawn to the board. The board is drawn BEFORE the last move.

EDIT: I fixed the drawing issue. Now, when checking for a tie or win I have the following check.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org