Knights Tour Issue(Probably easy) : I am attempting to complete the infamous "Knights tour" Where the knight must move around the entirety of a chess board until it has no more options or completes the board. I am getting unwanted out of bounds errors on my "movement" code and can't figure out the issue. All help is appreciated!
		for (int v=1; v < 50; count++, v++){
		
		 int gen = rand.nextInt(8);
		 
		if (gen == 0 && board[rowpos + 1][vertpos + 2] == 0){
			rowpos = rowpos + 1;
			vertpos = vertpos +2;
			board[rowpos][vertpos]=count;
		}
		if (gen == 1 && board[rowpos - 1][vertpos - 2] == 0){
			rowpos = rowpos - 1;
			vertpos = vertpos -2;
			board[rowpos][vertpos]=count;
		}
		if (gen == 2 && board[rowpos - 1][vertpos + 2] == 0){
			rowpos = rowpos - 1;
			vertpos = vertpos +2;
			board[rowpos][vertpos]=count;
		}
		if (gen == 3 && board[rowpos + 1][vertpos - 2] == 0){
			rowpos = rowpos + 1;
			vertpos = vertpos -2;
			board[rowpos][vertpos]=count;
		}
		if (gen == 4 && board[rowpos + 2][vertpos + 1] == 0){
			rowpos = rowpos + 2;
			vertpos = vertpos +1;
			board[rowpos][vertpos]=count;
		}
		if (gen == 5 && board[rowpos + 2][vertpos - 1] == 0){
			rowpos = rowpos + 2;
			vertpos = vertpos -1;
			board[rowpos][vertpos]=count;
		}
		if (gen == 6 && board[rowpos - 2][vertpos - 1] == 0){
			rowpos = rowpos - 1;
			vertpos = vertpos -1;
			board[rowpos][vertpos]=count;
		}
		if (gen == 7 && board[rowpos -2 ][vertpos +1] == 0){
			rowpos = rowpos -2;
			vertpos = vertpos +1;
			board[rowpos][vertpos]=count;
		}
		else{
			System.out.print("You moved " +count +" times.");
			break;
		} 