In the world of Dungeon Golf, the evolution of our bots has taken the game to new heights. Let's dive into the transformation…
[h2]Old Bots[/h2]
The old ones simply aimed for the cup or the nearest corner they could spot. Super basic, right? They had a few extra rules like dealing with sand and slopes, making them sometimes go for powerful shots. But honestly, they were kind of blind to what lay ahead.
[h2]New & Improved Bots[/h2]
Now, the new guys have a completely different strategy. They simulate tons of shots, picking the best one. As long as the simulation is spot-on, the real shot should land where the bot predicts. But how do we get bots to decide which shots to even simulate? Well for this we use a theory called “phase space” (which sounds straight out of a Marvel movie).
[img]https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExNDdpb20zMTBrNTdwMTNicjc1c2s5NDB1MGprdG15cTFhOWtub2ZtZyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Q0cogwwn9KCZeimBH8/giphy.gif[/img]
[h3]What is Phase Space?[/h3]
Phase Space is a term used to understand or represent a system in terms of the parameters you can control. In this case, the complex problem of “how to make the bot take a good shot” is considered just in terms of the two things you control when taking a shot in Dungeon Golf - shot angle and shot power - and then plotted on a graph. Each pixel is a possible shot, with the horizontal axis is the shot angle, and the vertical being the shot power.
[img]{STEAM_CLAN_IMAGE}/43797336/39ac477f4774d6f5c669be0b0ab02734bff35e08.png[/img]
[h3]Narrowing Phase Space Search[/h3]
There are a huge number of searches that a bot could perform from any given spot (we could fill in every single pixel on that graph!), but it is possible to make educated guesses and narrow down the search a lot. The search begins with the bots' usual path finding (this is the basis for how the old bots work, drawing a route to the hole to try and get them pointing in the right starting direction) and that’s the centre of the horizontal search space. Then, we use a Gaussian Distribution to randomly select shots around that centre point, favouring the middle, but also searching either side of it.
[img]{STEAM_CLAN_IMAGE}/43797336/5cefb53d73055ea30487398ab1cdeea243acb068.png[/img]
The power is searched using a Triangular Distribution that favours higher power shots over lower power ones. The reason for this is that (generally) changes in angle have a more impactful effect on high power shots than lower ones.
[img]{STEAM_CLAN_IMAGE}/43797336/e42165d0a1ad6496e59bf5ae5d1514ccea3fe4b4.png[/img]
[h3]Scoring A Shot[/h3]
All that’s left to do is score the shots so the bot knows which one it thinks is best! Scores are adjusted positively on:
[list]
[*] Distance to the hole (and being in the hole being a very big plus point!)
[*] Monster kills.
[*] Opening chests.
[/list] And they get negative marks for:
[list]
[*] Landing in a monster’s Danger Zone.
[*] Ending up out of bounds (huge negative points - these actually get marked in black on the scoring graph).
[/list]
[img]{STEAM_CLAN_IMAGE}/43797336/037474fbc941ac2fda1279e1dc33fbdaeb8c5e80.png[/img]
Here you can see several red balls and might be thinking “but they’re closer to the hole so should have scored higher?” The reason the balls further back are preferable is that they are outside of the Dragon Guard’s danger zone attack range. The ones closer are receiving a slightly higher score for being closer to the hole but being marked down significant as they would end with the bot receiving a shot penalty.
[h3]Challenges[/h3]
The main challenge with this approach is making the simulation accurate. The bots have to use a separate copy of the level, but with just solid objects. Any inconsistencies between the simulated world and the real world result in the scores of the balls being inaccurate, and potentially the bot selecting the wrong power and angle, and the shot being terrible.
This is why you might still see bots taking bad shots around obstacles like drawbridges or moving walls - these dynamic obstacles aren’t in the Phase Space simulation for performance reasons, so the bot’s brain doesn’t know about them.
And mentioning performance - that’s the other major challenge. It is very expensive to simulate all these balls and it has to be done in a reasonable amount of time, otherwise you’ll be sat getting bored waiting on the bots to decide which shot to take! In the end we have tried to find a middle ground between quality of simulation, number of shots to try, and waiting time, with an eye on keeping a good experience on our minimum spec hardware.
[img]{STEAM_CLAN_IMAGE}/43797336/cd634d0c3a4a360ae931b1c37a0addfa66b9e69d.png[/img]
[h2]Conclusion[/h2]
So, does all of this background work on the bots pay off? Are they better at playing the game? Well, yes… actually a lot better.
[img]{STEAM_CLAN_IMAGE}/43797336/fe9081baa2cb862c8214c385ebb6c92ba05eb887.png[/img]
We ran the old bot and the new bot through Fortress Fairway (from our Playtest) 5 times each and, on average, the new bot was able to beat the course with 25 fewer shots. These scores may be better than what you would see in a real game since the bot was able to get the kills for the enemies and received no penalties from other players using abilities against it, but still a 25 point swing is pretty good stuff!
[h3]Are They Too Good?[/h3]
Due to this rise of the bots, we actually had to stop them from always taking the perfect shot! Without this we have our Necromancer figuring out ridiculously unfair feeling chip shots like this!
[img]https://media.giphy.com/media/sSPQ2d0ssdWBFmKb1J/giphy.gif[/img]
Hope you’ve enjoyed reading this deep dive into the clever technical trickery in our new bots!
See you on the course! ⛳🎮
The Ants 🐜
⛳ Follow us on [url=https://twitter.com/AntWorkshop]Twitter[/url]!
⛳ Join our community [url=https://discord.com/invite/AntWorkshop]Discord[/url]
⛳ Subscribe to our [url=http://eepurl.com/dvcEJv]newsletter[/url]