Smarter Golfing for the AI

Smarter Golfing for the AI

Hello folks!

I’ve finished implementing the next stage of the AI golfing in Boss Golf!

Until now, it would just take the straight line to the hole, and hit as close as it could. It didn’t matter if it would land in a bunker or not, as long as it was closer to the hole, it was fine.

Now, though, it’ll actually take a good hard look at the golf course based on its own stats, generate a couple of alternative shots, grade them, and then take the one that is most desirable.

To start off, we have a Vision attribute for the AI golfers. This attribute governs how much the AI will try to “think outside the course”. It dictates the field of view that the AI has when thinking about a hole. Higher vision means being able to explore areas well outside the straight path to the hole. Lower vision means trying to hit as forward as they can, and fail to notice other better areas of the course.

Let’s take the hole below for an example:


It’s a pretty straightforward hole. There’s some trees to the side and a massive waste bunker all around the area.

Now let’s draw some potential fields of view:


In the above image, we have three different fields of view:

  • Red is a golfer with high vision
  • Yellow is a golfer with medium vision
  • Cyan is a golfer with low vision

The red circle is the position where this shot is being taken, and the green circle is the location of the hole.

As said before, the Vision designates the search space for the AI to find a good shot. It’ll then iterate possible flight paths of the ball based in this search space, trying to get as close to the hole as possible, while also evaluating the terrain under it. The AI has come up with the following options:


These are the 6 best ideas that the AI has come up with. It’ll then score them based on how good a shot it is and how difficult a shot it is. Difficulty is calculated based on the club needed to reach that distance (1 Iron is god tier difficulty), as well as the terrain that it has to traverse, like below:


Red shows problematic terrain, such as the bunker or tall grass.

Green shows good terrain, such as the fairway and the green.

Now it isn’t as simple as choosing the shot with the lowest difficulty to “payoff” ratio. Or it would be too easy!

This is the point where the AI Confidence attribute can interfere with the AI’s thought process. The AI has a good idea about how difficult the shots are, and how high the payoff is. Next it’ll query its own confidence in order to help it choose. If it’s feeling particularly cocky, it may go for the high payoff, high difficulty shot. If it’s feeling not so confident, it may instead choose the lower payoff, easy to hit shot.

After choosing, the AI will then take the shot. But before it does, we add some fuzzy logic to its shot, to add the regular accuracy/power deviation that every player has.

And then it waits until the ball stops traveling and lands.

Once the ball comes to a shot, the AI will then reevaluate its choice, to see if the gamble paid off or not. If it projected to land on the fairway close to the hole, and it does, its confidence will rise a bit. If it instead landed straight on the bunker, AI confidence will lower, which can have other more significant impacts down the line!

Now this hole was very straightforward, and there would be very little variation between what a pro would do and what a beginner would do.

Imagine however that that little strip of fairway to the left of the main waste bunker actually had a clear shot to the green, like below:


This could give golfers with higher Vision an edge, as they would be the only ways able to see that kind of shot happening. It would also be a challenging shot, which would appeal to golfers that prefer challenging courses. With this one simple change, you could increase the challenge rating of the hole, and please more types of golfers!

So that’s it for now! Golfers are quite a bit smarter now, and their playstyles have just become a lot more varied if compared to before! So once 0.5 hits, you’ll be able to see golfers acting quite differently from each other, depending on your hole of course!

Next up is basically making sure things are working, and adding a better “idle” routine so that the AI wanders around in a more realistic manner. 0.5 should be available soon!

Thanks for reading!

Needy Golfers!

Needy Golfers!

Hello folks!

It’s been a busy week, but I was able to implement the first pass of the needs system for Boss Golf!


As it is, the golfer’s needs will decrease over time based on their own attributes, as well as the place they are in. It works more or less like this:

  • Energy: Decreases by walking around the course for long distances, walking on difficult terrain (paths are important!), hitting the ball, falling in the water. Increases by drinking energy drinks, sitting down on benches, standing around talking with friends. Later on, when I have a weather system implemented, high temperatures will make the golfers tire faster too!
  • Food: Decreases a specific amount based on the golfer’s physical attributes. Some golfers don’t need to eat as much as others. It’ll be good to place vending machines in key areas, and later on you’ll be able to better diagnose where the golfers are getting hungry, and adjust accordingly!
  • Drink: Keeping hydrated is important, and drinking needs will decrease faster than Food. Again, vending machines come in handy, or even simple water fountains.
  • Environment: This one is more interesting! It doesn’t decrease/increase by a set amount: instead, it’s base value depends on the environment that the golfer is in, according to their preferences. If a golfer likes the Links, with wide open areas and no trees, his environment meter will be higher in those areas; if the golfer likes woodlands, then trees will make him happy. As well as keeping everything in a good condition!
  • Social: This will decrease and increase according to the interactions of the golfer on the course (with other golfers, with staff, with you), and also dependent on the golfer’s personality. Some golfers will seek out contact constantly, which can be a hassle to the more quieter golfers. You may even need to ban some people!

Not only needy, the golfers now have their own thoughts!

The basic system for thoughts has been implemented, and golfers will come up with their thoughts based on the action that they did, and their current state of mind at that time. If he hits a nice shot, he’ll likely have a happy thought; unless his confidence is low, then he may shrug it off to luck!

For now the thoughts are a bit limited, but I’ll expand them prior to 0.5, as well as over the course of development. The current panel looks like this:


It adds a nice bit of flavor to the game too. Specially after I saw one golfer miss an easy putt and immediately think “I hate my life”. Got quite the giggle out of me!

And here you can see an animation of how the current character info panel looks like. A long way since the previous iteration:


The confidence system is also in, but needs a lot of tweaks, as is the case for most of the game.

Next up, I’m gonna tackle how the AI goes about the holes. Right now, the logic is very simple and they pretty much just aim straight down the hole, and hit as close as they can. Which is viable in some cases but if you place a strip of sand in there, they’ll just hit in the sand!

Stay tuned for more updates!