Golfer AI Sketching: Utility

Golfer AI Sketching: Utility

Hello folks!

Today I’ll be talking about another part of the AI of Boss Golf: Utility

Simply put, Utility is a value that determines how useful an action is for the AI to take at a specific moment in time. For example:

Take an enemy AI that has a health value and an ammo value. And it has only three possible actions:

 

  • Use Healthpack
  • Reload
  • Shoot

At the start of a conflict with a player, if the AI is at full health and full ammo, then the utility value of the first two action is pretty much zero: Shooting would be a much more useful action in that specific moment.

As the AI engages in combat with player, things get more murky. If the ammo is approaching zero, then the utility of the reload action increases; the act of reloading becomes more important than shooting as you need bullets in order to shoot. At the same time, as the health of the AI decreases, the utility factor of the use healthpack action increases, as the AI needs health otherwise it will die.

The way this calculation is done depends a lot on the factors and data that the AI has access to. If it knows that the player is at low health, then reloading first instead of healing might be a better option. If it’s a particularly coward enemy, it will give priority to heal itself instead.

And this is just with three possible actions; add in more actions, such as running, finding cover, dodging etc, and you get much more variety of behavior.

The same thing will happen in Boss Golf, specifically when it comes to deciding the type of shot to take along a hole. Let’s use a sample hole to illustrate how it would work:

tricky_hole
A tricky Par 3.

In the Par 3 above, hitting the green from the start seems like a solid choice. The hole is well within the 150 yard range, which is achievable by most golfers that take to the course. But even pros make mistake; and there’s a couple of factors that can affect the success of a stroke:

  • Wind
  • Confidence
  • Performance so far

Wind can drastically affect a stroke, making your ball go lower than expected, slower than expected, veer laterally.

Confidence can affect the quality of your stroke. Lower confidence can lead to slice/hook, lack of power, reduce your accuracy, among other things.

Performance so far. If the golfer has been having a great day, he’ll be more likely to take risks; If he’s playing his ultimate best, he might be more risk-averse in order to keep his good handicap; if he’s having a bad day, he’ll take even less chances in order to try and recover.

All of those attributes (and more) would affect the calculation for utility of the shot. For Boss Golf, the golfers would always calculate a specific number of shot (based on their attributes), calculate the utility for them, and make the choice.

Below I’ve simulated some potential shots and their results, to give you an idea of what could happen:

tricky_hole_results

Some golfers would try and keep to the straight brown shot, getting very close to the hole. Others might go the blue route since they’re lacking the confidence they’d be able to hit the ball across the lake in one go. Some might overshoot it into the green following the pink line because they believe they needed more power. The guy in the green line may have messed up his first shot due to lack of confidence. And the poor fella on the white line just sent it straight into the water hazard.

After taking the shot, the result would also affect his current attributes, affecting his next shooting decisions as a result. So if the shot landed where the golfer wanted or better, his confidence will increase, so he’ll be more prone to taking a risky shot next; by the same token, if the shot ended up going badly, his confidence could decrease, leading him to be more risk averse on his next shot.

And that’s about it. Now we know how the AI will be controlled (via State Machines) and we know how he’ll decide which action to take (via Utility).

But we’re still missing one key piece of the puzzle: the Actions themselves.

Boss Golf features an action system that limits the possibility/quality of actions by the attributes/ability of the golfer. A pro-level AI golfer will have more tools (read: shots) at his disposal than a first-timer out in the tee. He’ll know when to pull, when to push, when to chip, when to approach, and be able to use these actions when out in the green, whereas a first-timer will be limited to less imaginative and simpler shots. As they grow in skill, they’ll be able to add more shots to their arsenal.

All of that will have to be factored in by the player when designing the course. If it’s catered mainly to beginners, it makes little sense to have very difficult courses; if it’s catered to professionals, it would make little sense to have too many easy holes. This balance will be vital in the development of your golf course.

I’ll make a write-up about the actions on my next post this week. Writing about the systems like this has been very helpful in aiding me with visualizing how the system works and building it!

So expect AI integration by the end of this month, bringing life to your course!

That’s all for today folks!

One thought on “Golfer AI Sketching: Utility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s