Deterministic turn based navmesh pathfinding algorithm with agent avoidance

I am developing a game in Unity.

In this game, 2 teams will fight without any human interaction. The fight results must be always the same, if the same teams are the same. This way, I must reproduce the same fight in many devices, getting the same results in each device.

The map where the fight happens is a 3d environment, so, my soldiers can move in any direction. And the soldiers cannot walk in the same space of another soldier, so I need an agent avoidance algorithm.

I am having some trouble to find a solution to the problem above. To achieve the 'always the same results' I am treating this fight as Turn Based Strategy game, with little fixed time intervals between the turns.

To calculate the paths of the soldiers, I am using the Unity navmesh framework. And then I manually move my agents according to the 'NavMeshAgent' 'steeringTarget' property.

But this method doesn't cover the obstacle avoidance algorithm, and my agents overlap each other.

So, I am looking for a solution to my problems, It should be a manual obstacle avoidance algorithm, or a way for Unity's navmeshbto work in fixed time intervals, or a completely new approach to my path-finding problems.

• Are your soldiers walking on a grid? Or is it more like, all players have X number of units they can move every turn, at any direction and speed (including something like 0.01)? Jul 26, 2018 at 11:08
• The second one. I already took care of that! I used some steering behaviors described in "gamedevelopment.tutsplus.com/series/…" to control the moviment. Jul 27, 2018 at 17:10
• When you've solved your own problem, it's best to post an Answer explaining your solution, not a comment. When a question has no upvoted/accepted answers, the system continues bumping it for eternity, assuming you still need new answers. Aug 2, 2022 at 12:22

The way to solve it in two steps:

1. Make your 'avoidance algorithm' prevent NavMesh movement from navmesh.SetDestination() when near another object with navmesh.Stop()
2. With Random.seed you will be able to set destinations of your navmeshobjects exactly the same on every device so outcome will be exactly the same if people are using the same seed.
• 1. Yep, this is technique that I am currently using. The problem is the 'Collision Avoidance'. After posting this question, I look into the 'Steering Behaviors' tutorials (gamedevelopment.tutsplus.com/series/…) and they gave me a way to manually implement the collision avoidance. 2. Thanks for the tip. Actually, since my server should be able to process more than one match at same time, I am using a custom Random algorithm, but this stage is already implemented! :) Jan 25, 2018 at 10:41