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:

AIExample

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:

hit_all

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:

hit_locations

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:

desirability

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:

pro_hit

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!

Going Clubbing!

Going Clubbing!

Hello folks!

For today’s update to Boss Golf, I wanna talk about clubs!

So I’ve implemented a system that now makes use of proper golf clubs when playing the game. Until now, the AI had access to “infinite” clubs; it would decide how to shoot based on the maximum distance it could achieve, and how close it was to the hole. Based on this, and information regarding maximum/minimum angles/distances for each club type, a trajectory would be generated and that would be that.

This meant that even if the AI was in a bunker, it could still use an Iron to drive out of it in massive distances.

That’s not very likely in real life!

So I finally went ahead and implemented clubs. Now we have clubs divided into basic categories, representing the main club types (wood, iron, hybrid, putter, wedge), all further categorized into their respective numbers and/or types (1 Iron, 2 Wood, Sand Wedge etc).

Each club also has a difficulty rating (cause lord knows not even god himself can hit a 1 Iron!), which will be factored into the decision making process.

Further, each AI will have a limited number of clubs in their little AI golf bag. No more infinity clubs; they’ll have their 14 clubs and that’s that. Makers will be implemented later, giving slight deviation to angles and maximum ranges, adding even more variation to an AI’s arsenal (and other income avenues for your club with a pro shop!).

For now, these are being generated semi-randomly at the start of the game. Later on, when the AI generation becomes based on the database, these will be recorded and AI will routinely change their arsenal.

Now I’m onto implementing these new clubs into the shooting decision making. I’ve created a new “GolferBrain” class, which will be used by the AI to determine their “best” option for their current shot. Basically, it’ll generate a handful of potential shots, grade their likelihood of success, difficulty, payoff, and use the golfer’s confidence to decide on which one to take. And then shoot it! And hope for the best! And watch as their perfectly thought out strike lands in the bunker, or the fire hazard!

After this is implemented for the AI, I’ll roll it out to the Player as well. You’ll also start with a right now randomized bag of clubs, and later on you’ll be able to change your collection to better suit your playstyle.

That’s all for now folks! Stay tuned for more AI updates!

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!

myneedsforahorse

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:

deepthoughts

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:

charPanels

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!

 

Smooth Terrain Testing

Smooth Terrain Testing

Hello folks!

Talking to a player of the game, he gave me the feedback that he didn’t quite enjoy the landscaping because the current terrain system looked a bit too unrealistic. Plus the looks of it looked a bit odd depending on the lighting conditions: the light would reflect too strong in certain areas, not strong enough in others.

So I went ahead an prototyped a simple replacement for it. Basically, I added a Terrain object to the game, and am using the existing systems for processing the information, while setting the height of the terrain based on it.

The results are here:

terraintest

I quite appreciate the smoothness of this terrain. With the proper texturing, it could look pretty sweet and clean. I’m studying how to apply the terrain textures to it (grass, gree, fairway etc), but since this has a decent support for normal maps too, it could add some much welcome depth to the terrain features.

It is, however, a trick. The mesh is still pretty much the same as it was before (at least at this stage), and you can see the difference when I turn on the wireframe mapping and some zones:

smooth_editing

But the smooth shadow makes it look a lot nicer. Playing around with some height limitations, I could make the height tools affect nearby vertices as well, to give a smoother climb. There’s no performance loss either at this stage, which is great.

I’m gonna prototype how to apply the terrain textures to it, but I have a hunch it would allow me to more easily use higher-res tiles. And for the zones, I can just keep the current system as they work decently enough as an overlay.

Considering some changes to the planning aspect of it too, but that’s for later!

That’s all for this microupdate!

-Gus

Needs, Moods, Confidence

Needs, Moods, Confidence

Hello folks!

Today I’ll expand upon the basic system driving the golfer’s state in Boss Golf!

It is very common for tycoon type games to have a sort of happiness/needs meter for the guests to your park/hospital/zoo/dinosaurland. This is one of the main aspects of gameplay in those games, and you as the tycoon have the sole objective to fulfill their needs while extracting the money out of them.

But in most of the games, guests are reactive actors. They go on rides, get their share of adrenaline, eat some food, drink some drink, spend some money, and go home. Most of their actions are reacting to their needs at any given point.

With Boss Golf, that wouldn’t work as well: we also have to factor in the activity of playing golf, the main driver of the AI’s state in the game.

Therefore, for Boss Golf, I’m implementing a system based on 3 “meters” of sorts: Confidence, Mood, Need.

Confidence

The confidence meter affects and is affected by the golf gameplay of the AI. However, instead of being a universal boon/curse, it is a double edged sword. Being too confident can lead to complacency; lacking confidence may lead to lucky breaks if your confident opponents get complacent.

In terms of affecting the gameplay, it works basically like this:

  • Higher confidence means attempting more difficult/risky shots if the AI thinks the payout is worth it
  • Higher confidence can also mean going on autopilot since the adversaries aren’t playing as great as the AI, so they think they can relax
  • Lower confidence means playing more safe/easy shots
  • Lower confidence can also lead to more consistency over the holes, as safe shots tend to land better than risky shots

In terms of being affected by gameplay, it works roughly like this:

  • Landing a good stroke, with little deviation, will increase your confidence
  • Landing in a lucky position will increase your confidence
  • Slicing/Hooking your shot will decrease your confidence
  • Landing in the wrong place will decrease your confidence

Other “passive” factors can also affect confidence, such as rivals playing badly/godly, external life events, divine inspiration…

And the increase/reduction isn’t on a simple scale. There are diminishing returns for increasing confidence depending on your current confidence level; there are also increasing returns for decreasing confidence depending on your current confidence level. Overconfidence and hit the bunker on an easy shot? Your confidence will shoot down. Unsure and hit a successful shot? Your confidence will increase well, as you played exactly the way you wanted. If it was a lucky shot, your confidence could remain the same or even diminish, as you wouldn’t believe it would happen again.

Mood

Mood is the overall happiness of the golfer as he’s visiting your course and playing the golf.

It can be affected by quality of play, by the environment, by special events, and mainly by the fulfillment of the golfer’s needs.

In Boss Golf, however, each golfer’s mood over the day is like a tiny “Hero’s Journey“. It isn’t important just to have a “good” experience on the course: golfers want a meaningful experience. And they each have their own idea of what their meaningful experience is, affected by their own personality traits and whatnot.

Basically, over the course of the day, each golfer has their mood map built. This is done by taking snapshots of the golfer’s mood every ingame half hour or so, and whenever a special event happens. This little mood map is available for the player to look at on the character’s panel in the form of a nifty graph. This graph will also show the “ideal” values that this golfer has for his meaningful experience.

So at the end of the day, the golfer mood map is compared to his threshold for a meaningful experience, and a rating is assigned to it, ranging from F to S. (S being Super Meaningful) (This is a good thing). Good ratings means satisfied golfers; satisfied golfers mean $$$!

This microgameloop will revolve around hitting as many of those beats as possible for the highest number of golfers. The more meaningful experiences your golfers have, the more likely they are to become members, make donations, spread the popularity of your course. Of course, you can’t please them all, so you’ll have to be careful when you build your golf course experience.

Need

Needs are the most basic and simplest feature to explain. These are the basic requirements that the golfer has to be an actual functioning boss person walking around your golf course. It is divided into 5 categories:

  • Social: contact with other golfers, with your character, with staff.
  • Food: golf is a sport, and practicing sports requires energy, and food gives you that. Can also poison you, though!
  • Drink: keeping hydrated is important, and the proper drink can give you an edge. Or take the edge off.
  • Energy: golfers are people too! And energy is required for performing actions. If your golf course is large, you’ll want to have carts available to help save some energy. If your golf course is small, you may want other activities so that the golfers can expend their energy.
  • Environment: no golfer likes a dirty, ugly, unsightly golf course. They want beautiful vistas, peaceful views, and consistency. You’ll need to wear your boss landscaper hat to fulfill their dreams.

Satisfied needs will increase the golfer’s mood. Unsatisfied needs will decrease your golfer’s mood. Other events can also happen depending on the level of each need’s fulfillment. You may end up with drunk golfers falling all over the course, passed out golfers, golfers who are depressed because they feel alone in your course…

And that’s about it for now. I’ve begun implementing this system this week, so this will be featured in 0.5, and your boss golfers will become more human. Or simmish. Each mood, need, confidence, will have an impact on the golfer’s thoughts, and you’ll have a direct window to each golfer’s mind. Kind of like Being John Malkovich.

Who knows, maybe I’ll even implement a feature that puts you inside the golfer’s mind, seeing things from their point of view!

Hope you enjoyed this writeup!

-Gus

Procedural Colliders and 0.44

Procedural Colliders and 0.44

Hello folks!

So, turns out implementing procedural colliders was easier than I had anticipated, so I did it! This should hopefully reduce the incidence of AI characters falling through the ground! At least during testings in the editor, I left the game run for a couple of in-game days, and there was no error messages of them falling through. So it should be good!

Here’s it in action:

procedural_collisions

You can see the grid of 9 or so cubes walking under the player character. This way the character is guaranteed to be standing on solid ground even as he walks.

So, NOW, I’m done with 0.4! And I can focus on 0.5. For real this time you guys. Already began scripting some of the new AI behavior that currently breaks the game because it’s not fully implemented! So, no turning back now!

In any case, enjoy! You know where to find the alpha by now, and if you haven’t signed up yet, you can still do so here!

-Gus

Good Path – Bad Path: Alpha 0.43

Good Path – Bad Path: Alpha 0.43

Hello folks!

Time for another quick hotfix for Boss Golf!

This one declutters a couple of things and improves others. Fixes include:

  • AI movement path display is off by default. To see where the AI wants to go, click on it! For 0.5, you’ll have a little display panel showing what the AI is trying to do, where it is trying to go, what it is currently thinking…
  • Disabled Water as an obstacle for the pathfinding of the landscaper. Now he’s allowed to walk on water.
  • Improved resolution of the text.
  • Added a safeguard in case the AI falls through the floor. Not 100% yet, as that will require proper implementation of a dynamic convex collider generation, which will take some time to implement

For an illustration, here’s what used to happen when the AI tried to plant grass over the water:

bad_path

It actually tried to create a path through 90 different tiles in order to get to the goal. Now with the water avoidance turned off:

goodpath

Much better! Later on I’ll add a little boat effect for when the landscaper dude goes into the water. A bit of a playful kind of thing!

That’s all for now. This should hopefully be the last little hotfix for 0.4, and now I can focus on doing 0.5 stuff! Stay tuned for some cool new features!

Enjoy!

Alpha 0.42!

Alpha 0.42!

Hello folks!

Thanks to some very quick feedback, I’ve done some fixes to alpha 0.4, bringing it to 0.42!

Here’s what’s changed:

  • Added a hashing effect to the planning tiles so you can better distinguish between them
  • Increased movement speed for AI characters
  • Reduced time for placing tiles/decoration
  • Balanced the scale randomizer of the decoration tiles
  • Improved the presentation of text in the UI, much more legible now!
  • Fixed issue with the ball being always visible even behind objects and stuff
  • Fixed not being able to place decoration pieces on planning tiles
  • Made some menus close when opening other menus, to reduce clutter on the screen

So quite a nifty list!

Still, there’s some issues with the AI simply stopping the play of golf. It could be that they accidentally fell through somewhere. In that case, simply restart the game and it should fix it. Since it’s a more difficult issue, I’ll need to take a closer look at how to work around it.

That’s all for now, folks!

Enjoy!

Boss Golf Alpha updated to 0.4!

Boss Golf Alpha updated to 0.4!

Hello folks!

It took a little longer than I expected, but the closed alpha for Boss Golf has been updated to 0.4!

alpha_04

Some of the changes included in this update:

  • Tile and decoration execution moved to the landscaper
  • Resort’s opening and closing time now matter
  • Bulldozer only affects planned zones (can’t remove decoration pieces yet)
  • Money and transaction recording system implemented
  • Spaced out the loading of the scene and added a loading screen
  • Decoration system reworked to allow for more freedom of placement
  • Order system revamped to work with decorations and tiles

Because of the array of changes in this version, your 0.3 save change won’t be compatible with this new release. It would take me a lot of precious time to create a save converter at this moment.

The changes in decoration are quite massive, though. The previous system will still be used for the scenario editor, where you just really wanna sketch out the level for your scenario. But this new one gives you a lot more control over placement, so that you can really customize things to your liking. If you have any request for tools or feedback, feel free to comment on our reddit or our discord!

So that’s it for 0.4. It drastically changed the flow of gameplay, slowing things down quite a bit, and implemented a host of systems that I’ll take full advantage of in development.

For 0.5, I’m going to focus on the AI again, giving them proper ways of evaluating/thinking a hole, more behaviors, more character generation, and a couple more things I wanna keep under wraps for now! Timing for 0.5 is early March.

Enjoy!

Assuming Control of Decorations

Assuming Control of Decorations

Hello folks!

Today’s update is one of the last big ones for 0.4! And it’s about Decorations in Boss Golf!

As you remember form the beginning of this update cycle, I mentioned how I wanted to take a turn to slow things down in the game. As part of that, I created a new system for placing the tiles, whereas the little landscaping guy would go and place the tiles after you finished setting up and approving your order. (If you need a refresh, you can read about it here!

Of course, this wasn’t going to be limited just to the tiles! Same will apply to buildings, facilities and, of course, decorations! In 0.3, you are able to place trees like you would any tile. Continue clicking and more trees will appear, and their position is randomized. You could also drag over a large area and place a bazillion trees at once.

This capability will be maintained in the scenario editor, where you will want broader strokes when building a scenario.

For the regular game, though, slowing things down is necessary. As such, I’ve altered the decoration system to bring you more freedom of placement, and work it into the current landscaping system.

For most decoration pieces, you the manager will place down the markers for where you want that decoration to be. Then the little landscaper that could will come and plop them down for you! As below:

placing_trees

So now you can place your decoration anywhere. Well, mostly. But feedback can always change one’s mind! But this will give you enough flexibility to really beautify your course. And you’ll be able to see your course grow over time and whatnot. Later on also planning on adding the possibility of moving a piece of decoration you placed, so that you don’t need to pay the extreme fees for new trees and whatnot. Saving is caring!

Together with this, I revamped the order system to make it more modular, so that I can more easily expand to accommodate different types of orders and whatnot, and revamped the decoration system to also make it more modular, with an eye for modding potential in the future.

All in all, a solid update. Now I need to readjust the save files to take into account the new changes, and 0.4 should be delivered to you guys soon!

(And if you haven’t signed up for the closed alpha, do so here! You kind folks who support the game at this stage will have some goodies and bonuses for believing in Boss Golf!)

That’s all for today, folks! Stay tuned for 0.4!