Next card selection consist of few steps:
- find all cards in search field.
- calculate distance from current position to each card
- select N closest
- randomly select 1 from the closest N
where N is "randomization factor" (from how many closest to choose one)
Now if there are more cards with the same distance, than N only N will be used selecting one.
But it sounds wrong because all those have the same value for the task.
Here is the algorithm how it should be:
1. Select the closest (all if there are more than 1 on the same distance) from the those in search field
2. if there is enough cards in Selected proceed with 3 otherwise 1
3. choose one randomly from Selected