wessonsm, no need to worry about it
Well, I come up with another question with BU:S summoning, I want to write a function with the following requirements, and I'd like to know the best approach to it.
The task of the function: Find a random but closest position to the given position for BU:S summoning. The monster for summoning is known for whether it is double wide, and the side for summoning.
Input: a known Position, Is Double Wide, Side.
Output: Closest position to the known position for BU:S
I have two approaches in mind, first one:
- loop through all the hex on the battlefield
- Check the distance between the looped hex and the known hex
- Collect the hex with the smallest distance and put to the array
- Get a random position from this array
Second one:
- Check for the closet positions around the given position. The first batch would be the six hex around the target
- If none is available, check for a larger hex around the target, repeat this if nothing is found again
Basically, the first approach is easier to code, but I am worried about its efficiency. The second approach should be faster, but it is a bit tricky to code. If I can't combine the steps, I might end up checking for every single position manually.
Any thoughts?