Forums

Help › Forums

Re: Fair wind...

rated by 0 users
Wed, Sep 15 2010 4:35 PM (8 replies)
  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 1:33 AM

    Just got out of a KIA18 or F9 RG where I had 17-20 wind directly in my face for holes #2, #3, and #4, which is bad, and then on hole #5, a par 3, I had wind 18 wind from my back, which, of course, meant that I couldn't stick it on the green.  Then, on 6, I had wind in my face once again.  I don't remember the rest of the wind, other than #8, the other par 3, where I once again had 18 wind or so from my back, which again meant that I couldn't stick it on the green, but nonetheless, I was grumbling about it by hole #4.

    I know a lot of people have complained about the wind in the past, and I've been told it is completely random (only reason I've seen given is to prevent some sort of exploiting,) BUT!  This thread is different.  I know that coding extra features can be a bit of a pain sometimes, so I am going to write the code, here, in c++, and all you guys will have to do is port it over to whatever language you're using.

    Assumptions that I am going to be making are that you are using OOP and have a "round" class for each round of golf created, and in each "round," 9 or 18 holes are loaded into an array within the class, i.e. "round.hole[9]", and also that there are other variables that are accessible by "round.hole[i].wind_speed" or something similar.  Of course, I'm not going to declare these, since you almost undoubtedly are using OOP, and thus have a "round" and/or "hole" class, and that these variables are contained in these classes, which means the classes' constructors have already taken care of declaration.  I'll make note of variables that you most likely do not already have in the "round" (or hole) class and will thus need to add, and I'll declare all of my local variables that will be discarded once this/these procedure[s] is/are completed.  The variable names may not be exactly the same, and you'll perhaps have to change a few things, but nonetheless, it's free code, and not only going to make wind completely fair, but it is also going to keep wind completely randomized, and you will never get a complaint about bad luck with the wind ever again!

    The first reply following this post is going to be explanation/pseudocode, the next is going to be step-by-step conversion of chunks of the pseudocode  into c++, and the third post is going to be 100% code (with reasonable comments.)   It'll only take me an 2 hours or so to write the code, but it might take 24-72 hours for me to actually get around to completing everything.  :P

    If you guys end up implementing it, that would be very cool, and I think pretty much everyone would want that.  If not, no biggie.

  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 1:34 AM

    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)


  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 1:34 AM

    Conversion post.

  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 1:34 AM

    Code post.

  • Doublemochaman
    2,009 Posts
    Wed, Sep 15 2010 8:09 AM

    Whew!  The only code I'm doing at 1:33AM in the middle of the night is "dream code".  With some alpha or beta waves thrown in...

  • Richard4168
    4,309 Posts
    Wed, Sep 15 2010 11:45 AM

    LOL!!  Dude carried on a conversation with himself.

    Charle, what the hell are you talking about? On second thought, don't answer that.

  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 12:49 PM

    Richard4168:
    LOL!!  Dude carried on a conversation with himself.

    Charle, what the hell are you talking about? On second thought, don't answer that.

    Hello, Richard.

    Instead of logging onto the forums and being passive aggressive and attempting to justify why I believe the game should put me on shorter tees in order to make up for my lack of playing ability, I am trying to help make the game better by not only making a suggestion, but also doing the work for WGT.

  • Richard4168
    4,309 Posts
    Wed, Sep 15 2010 2:06 PM

    CharlemagneRH:
    in order to make up for my lack of playing ability,

    We all thought you were a WGT god and didn't need to hit from shorter tees.

    CharlemagneRH:
    I am trying to help make the game better by not only making a suggestion, but also doing the work for WGT.

    Why work for free? Send you're resume to WGT.

  • CharlemagneRH
    1,054 Posts
    Wed, Sep 15 2010 4:35 PM

    Richard4168:

    CharlemagneRH:
    in order to make up for my lack of playing ability,

    We all thought you were a WGT god and didn't need to hit from shorter tees.

    I largely don't need to hit from the shorter tees to beat an honest TM or pro, but sandbaggers are another story.  Luckily, it's my belief that WGT is addressing the sandbagging issue.

    Richard4168:
    CharlemagneRH:
    I am trying to help make the game better by not only making a suggestion, but also doing the work for WGT.

    Why work for free? Send you're resume to WGT.

    I don't need the money, but thanks for your concern.

RSS