But I would generate single array of valid positions first and then generate single random value in 0..array_size - 1 range. Value under generated index will be the result.
---------------------------------
Another variant is to fill "positions" array of 186 items with 0..185 values correspondingly.
Also define variable numCandidates = 186 (array size).
Repeat until free position is found or numCandidates = 0.
Generate random value in 0..numCandidates - 1 range.
Battle pos = positions[generated random index]
If position is not free or invalid, then
positions[generated random index] = numCandidates - 1; we make array index to actually point to another position, thus virtually removing tested hex from further check attempts
numCandidates = numCandidates - 1; decrease positions array size, because the last position is not referrered by "generated random index".
------------------------
For instance, imagine there are max 8 positions on battle: 0..7.