How it works...

The algorithm traverses the whole graph, starting from the guilds' positions. Given our previous inverse subtraction, the priority queue always starts from the strongest node and computes the assignment until it reaches a value below the dropOffThreshold. It also checks for ways to avoid a new assignment if the conditions are not met, if the vertex value is greater than the current strength, or if the guild assignment is the same.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.