This is another portion of the same program referenced earlier. It's sort of like tic tac toe, but with a variable board size. I have already gotten my method for checking to see if anyone has a tic tac toe to work, but currently I have a different method for each board size, and each player, which gets really really long. I know there must be a way to only do it once. I was thinking nested forloops, but it doesn't seem to work with the logic I am using, as the x and y increment together. Some tips would be great. I need this to work for any board size, and check horizontal, vertical and diagonal win possibilities.

/** Checks the board to see if the player has scored any points by filling a row, column or diagonal with their pieces. If so, * player is awarded points for each space filled and pieces are removed from the board. @param gameBoard. @return gameBoard. * */ public static int[][] checkBoard3Player1(int[][]gameBoard) { boolean[] rows = new boolean[gameBoard.length]; for(int x = 0; x < gameBoard.length; x ++){ if(gameBoard[x][0] == gameBoard[x][1] && gameBoard[x][0] == gameBoard[x][2] && gameBoard[x][0] != 0) rows[x] = true; } boolean[] cols = new boolean[gameBoard.length]; for(int y = 0; y < gameBoard.length; y++) { if(gameBoard[0][y] == gameBoard[1][y] && gameBoard[0][y] == gameBoard[2][y] && gameBoard[0][y] != 0) cols[y] = true; } boolean diagLtoR = false; if(gameBoard[0][0] == gameBoard[1][1] && gameBoard[0][0] == gameBoard [2][2] && gameBoard[0][0] != 0) diagLtoR = true; boolean diagRtoL = false; if(gameBoard[0][2] == gameBoard[1][1] && gameBoard[0][2] == gameBoard [2][0] && gameBoard[0][2] != 0) diagRtoL = true; for(int x = 0; x < rows.length; x ++) { if(rows[x]) { for(int gbi = 0; gbi < gameBoard.length; gbi ++) { gameBoard[x][gbi] = 0; player1Score++; } } } for(int y = 0; y < cols.length; y ++) { if(cols[y]) { for(int gbi = 0; gbi < gameBoard.length; gbi ++) { gameBoard[gbi][y] = 0; player1Score++; } } } if(diagLtoR) { gameBoard[0][0] = 0; gameBoard[1][1] = 0; gameBoard[2][2] = 0; player1Score++; } if(diagRtoL) { gameBoard[0][2] = 0; gameBoard[1][1] = 0; gameBoard[2][0] = 0; player1Score++; } return gameBoard; }