Hex boardgame with fast random rollouts (OpenAI gym framework)
When reading this function alone, without any surrounding code, I wonder where the initial + 1 for the position comes from. That looks like an off-by-one bug to me. I don't know whether it is indeed a bug, it's just suspicious.
The calls to tuple() look redundant since the current_position already is a tuple. Doesn't your IDE warn about such things?
The word position is a bad name since it is ambiguous. It could either mean an (x, y) tuple or the complete (board, player_to_move) tuple, like in the sentence &quot;in this position, Red should resign&quot;. A better name would be last_move or prev_move.
Is there a good reason why you use a tuple at all? Having two variables x and y would make the code pretty clear. These variable names are short enough that you don't need the low_x and related variables anymore.
Do you need the call to tolist() at all?
Instead of generating a 2-dimensional matrix, it could be more efficient if you just took the 6 neighbor regions explicitly and individually. That way you also get rid of the pop(0). I don't know whether that is faster in Python though.