simulating

Published June 06, 2022
Advertisement

Before executing an action you need to run a predictive simulation to see if executing the action is a good decision or not. I`m attaching some images to aid my explanation about simulation.

I`ll be using a very well defined situation in my explanation to get rid of all the unknowns. My example is a situation on the Starcraft Lost Temple map: Player 1 needs to build an expansion and he`s not sure if sending an SCV to the lower ground expansion on the right is a good idea. Player 1 knows that there is a group of enemy marines waiting outside the high ground platform that the base if found on. Also Player 1 has a group of marines at the entrance of the ramp that leads to the high ground platform. So is moving the SCV to the expansion spot a good idea? To find out we place the SCV in each way point on the route to the expansion and run a simulated attack from the enemy marine group (for that way point specific position). If the route has 20 waypoints that`s 20 simulated attacks. In the scenario depicted on the image in order to reach the SCV the Player 2 marines (2.2) must pass by Player 1 group of marines (1.2), this will happen in every of the 20 simulated attacks. If player 1 group of marines is larger than player 2 group of marines will die in every of the 20 simulated attacks and hence will never reach the SCV. So in this particular scenario it is safe to send the SCV to the mentioned expansion location to build a command center.

When I say simulate an attack I mean you place the SCV on the way point an wait until the enemy reaches that location or dies on the route. Executing 20 simulated attacks might seem a lot but it really isn`t. You don`t have the 'thought' of sending SCV to the expansion location constantly say several times a second, you run the 20 simulated attack once reach a conclusion then reconsider sending the SCV again only when conditions have changed (which could be a couple of seconds or minutes). In other words running simulated attacks is not something you constantly do, you reach a conclusion and then take a break.

I`m not showing the paths the player 2 marine group will take in those 20 simulated attacks, it would just clutter the picture.

Previous Entry Pathfinding
0 likes 2 comments

Comments

JoeJ

You don`t have the 'thought' of sending SCV to the expansion location constantly say several times a second, you run the 20 simulated attack once

It may end up more complicated, because we do realtime applications.
If your simulation of 20 attacks takes too much time, you may miss the frame.
Notice it does not really matter that you have to do it only once. A dip in framerate is just as bad as a constant, but low frame, which you would get if you did the simulation each frame.

This brings some problems difficult to tackle. You may run the simulations async in its own thread. Or you may make sure the simulation can be interrupted to render the frame, and can continue after that, again with just a fixed budget of processing time.

Maybe that's an exaggeration, but that's an advanced example from the kind of problems we get from realtime constraints. That's why i proposed you make your game interactive as early as possible, so such problems are noticed and fixed early.

Btw, i would aim for approximate optimization here: Instead doing 20 attacks, find the closest segment of the path to the enemy.
Can the enemy reach this location in time? Yes → simulate just one attack there, using probability and heuristics to predict its outcome. No → It's safe to take the path.

It's not exact, but likely good enough. And you can do more such simulations to increase complexity, and eventually get a more interesting game out of that.

June 06, 2022 10:50 AM
Calin

That's why i proposed you make your game interactive as early as possible, so such problems are noticed and fixed early.

We are talking remote future plans here, I`m not even at base building AI yet (base building AI the old approach)

It may end up more complicated

Thanks for pointing out all the implications.

June 06, 2022 11:48 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement