Explanation
First off, explanation/psuedocode time.
On each hole, wind in eight different directions (N, NE, E, SE, S, SW, W, NW) will be assigned a "favorability" rating (integer), where:
- -2 means very unfavorable
- -1 means slightly unfavorable
- 0 means wind in that direction is neither good nor bad
- +1 means slightly favorable
- +2 means very favorable
Taking KIA 11 as an example, "very favorable" wind would be wind to the North, "slightly favorable" wind would be wind to the NW or NE, wind to the E/W would be neutral, wind to the SW or SE would be "slightly unfavorable," and wind to the South would be "very unfavorable." This should take all of 60 seconds to do, per hole.
In every round, these favorability ratings should add up to 0, or close to it. In other words, if you get really bad luck with the wind on one hole, you will be assured really good luck with the wind on another.
So, once again, the first step would be to consider the wind off the tee and also the approach shot, for every hole, and assign different favorability ratings based on these two shots.
After these data are entered, comes the code that picks the wind, keeping these ratings in mind.
Pseudocode Overview
Pick a random number out of the following numbers: -2, -1, 0, 1, or 2. *
Starting with the first hole assign it to a hole, assign it that wind favor rating, and then assign the opposite (i.e. -1 * wind_favor) to another random hole, assuming that hole has not already been assigned wind. **
Repeat until all holes are assigned wind.
* Making the random number generation process favor -2 and -1 (i.e. unfavorable wind,) or neutral wind, or +1 and +2 (i.e. favorable wind) over
the others is possible, but I will leave that up to you.)
** Three different implementations will be provided for this: (1) one which should be somewhat fast, but not completely random in its assignment of the opposite wind rating, and (2) a linked-list solution that would be completely random, and (3) scrapping the "pair" idea (i.e. a +2 rand will result in another hole being assigned a -2, etc.) entirely and simply traversing the array of holes, assigning wind favors randomly, but keeping a running tally of the wind favors, making sure to not go too far negative or positive -- a solution that would be very fast. Implementation #1 will be referred to as "Array Traversal," implementation #2 will be referred to as "Linked List Scramble," and implementation #3 will be referred to as "Running Tally."
Pseudocode (Array Traversal)
Add a "wind_favor" variable to the "hole" class or simply create a temporary array here.
int temp_wind_favor, current_index, start_index
for each hole in round (i as iterator)
...if hole is not assigned wind favor
......temp_wind_favor = floor (rand(5) - 2)
......
rand() is inclusive, so if temp_wind_favor is +3, set it to +2.
......set hole[i] equal to temp_wind_favor
......randomly select another hole to assign the opposite wind favor rating to
......if that hole is already assigned wind, move to the next hole until a hole that has not been assigned wind favor is found; loop around to the front of the list of holes if the last hole is reached and already assigned wind favor, and exit out of wind_favor-assignment if we once again find ourselves at the hole at which we started (i.e. if current_index == start_index)
...close if: hole not assigned wind favor
next hole in round
for each hole in round
...look up wind directions matching hole's wind favor rating that was generated above
...assign wind direction (+/- 22.5 degrees) based on wind favor ratings generated above
next hole in round
Pseudocode (Linked-List Scramble)
// RG break!
Pseudocode (Running Tally)