Skip to content

Instantly share code, notes, and snippets.

@LiamKarlMitchell
Last active June 11, 2020 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiamKarlMitchell/1274ea5bcf3e634aa31449f1c98b9cfb to your computer and use it in GitHub Desktop.
Save LiamKarlMitchell/1274ea5bcf3e634aa31449f1c98b9cfb to your computer and use it in GitHub Desktop.
League of Legends interesting things.

Archived from http://web.archive.org/web/20200308182225/https://boards.na.leagueoflegends.com/en/c/developer-corner/qRHotV9k-minion-ai-rules-documentation and converted to markdown/niceness to read.

Found archived topic on here: https://www.reddit.com/r/summonerschool/comments/99d6my/riot_minion_ai_behavior_documentation/

Hello! I’m Riot Reinboom and I’m here to drop some Sweet minion AI game documentation on you all.

What? We’re sharing our understanding of how a bunch of weird behaviors of how lane minions work internally and figured it would be informative for you all as well.

So, documentation. Exciting stuff.

This won’t cover the behaviors of all minions and instead just covers lane minions (hereafter just referred to as minions). Primarily, this will focus on some of the more quiet features. This is all also Summoner’s Rift specific.

Other maps and modes may change these rules (though, usually not).


General Minion AI Rules

Lane minions have a “list” of actions they check if they can execute, following through with the first valid action they reach and ignoring the ones after that.

Minions always have a “goal” they’re trying to fulfill in some way.

Even while walking, they’re actually moving towards a specific point that keeps changing as they get closer to it.

The Behavior Sweep

Every 0.25 seconds, each minion will go down a checklist of options until it finds a valid one to do. It won’t follow invalid actions, and it won’t follow actions after that. This means that in this list of options, the catch-all default option is last (walking towards a waypoint).

AI Priority List

  • Follow any current specialized behavior rules, such as from CC (Taunts, Flees, Fears)
  • Continue attacking (or moving towards) their current target if that target is still valid.
  • If they have failed to attack their target for 4 seconds, they temporarily ignore them instead.
  • Find a new valid target in the minion’s acquisition range to attack.
  • If multiple valid targets, prioritize based on “how hard is it for me to path there?”
  • Check if near a target waypoint, if so change the target waypoint to the next in the line.
  • Walk towards the target waypoint. If a minion can’t follow any of these behaviors, it will do nothing. Minions have a lot of checks to note whether or not a target is valid or not. There’s obvious ones like “which team is the target on” but also non-obvious ones like “where on the map is my target”. Many of these will be covered further down.

Interrupts

There’s also a number of things that can occur between the 0.25 second interval of the normal sweep through the AI Priority List. There is no particular order to these.

  • Taunt/Fear/Flee/Movement Disable/Attack Disable. All of these cause a minion to freshly reevaluate its behavior (following the AI Priority List) immediately.
  • Call for Help. Minions ‘hear’ signals from nearby minions and champions being attacked (even by other minions). This causes them to recalculate their current target and prioritize the attacker that caused the Call for Help.
  • Collisions. Minions that end up overlapping other minions will reevaluate their behavior immediately. This usually causes them to shift around to get off each other.
  • Their current attack target dies. Minions who witness the death of their foe will check for a new valid target in their acquisition range.

Waypoints

When lane minions spawn, they get assigned to a list of points (the waypoints) that follows their intended lane. By their default behavior, minions will always try to move towards the next waypoint. If they get near that point (with a rather large circle around for “near”), they will change their waypoint target to be the next in line.

All waypoints eventually lead to the opposing nexus. For a lane, waypoints are the same for both teams. Each team just changes the direction it searches for the next waypoint in in the list.

An example of some of the bottom lane waypoints and some lines showing the group they are in: #Ranges Lane minions have three primary ranges: Collision, Attack, and Acquisition Here’s a melee minion showing all three of these ranges: Acquisition Range In the image above, Acquisition Range is represented by the largest circle (red).

When minions sweep for valid targets, they look only to this range and no further.

Attack Range In the image above, Attack Range is represented by the second smallest circle (bright green). When minions try to attack their target, they must first get them within this range.

Collision Radius In the image above, the Collision Radius is represented by the smallest circle (black). This is the radius for which all other ranges must reach in order to be valid on an opposing unit. In many games, this is also known as the hit box.


Specialized AI Rules

Minion behavior can change dependent on the area of the map they’re in and/or based on when they were spawned. The most important of these are: The First Minion Wave and Region Avoidance.

First Minion Wave

The first minion wave has modified behavior.

This behavior difference is meant to ensure a that if the first minion wave goes untouched, the minions deaths in that lane are almost mirrored for both teams through at least the first minion wave.

There’s a few things we need to control for in order to ensure a balanced outcome. These are:

  • Minions update every 0.25 seconds. Increasing this isn’t reasonable as it strains the game servers to do so.
  • Minions spawn with a notable gap between them and carry this pace when walking to lane. This gap means that when a minion finally sees an enemy minion, it sees only that enemy minion.
  • Minions like to reevaluate their current target for potential better targets a lot. This is why their behavior feels erratic. This is primarily caused by Call for Help and Collision. There’s also some possible solutions we’ve tried in the past that show harder to pin issues of the AI. For example, when we made minions assign their initial targets at spawn it caused top lane and bottom lane minions to take a tighter turn to get to their target, pulling the whole wave closer to the river. In order to get minions dying in an orderly fashion early in the game, and dealing with the above constraints and discoveries, the first minion wave has numerous AI changes.

“Distribute Fire” Prioritization

The first minion wave prioritizes targets with fewer allies already targeting that enemy. This causes them to naturally distribute their focus.

Temporary Caster

Minion Ignore When searching for their first target, they will ignore any caster minions they find. This ensures that a melee minion doesn’t run to the unfocused caster minion line when trying to distribute fire. Caster minions will still wake up a minion (see “Multiple Acquisition Ranges” below). If after 0.25 seconds a minion still hasn’t found a valid target other than the a caster minion, it loses the caster minion ignore rule.

Ignore Allied Collision before lane

The first minion wave ignores all allied collision before they pass the first turret. This ensures that allied champions can’t manipulate the specialized behaviors of the first minion wave.

Radio Silence

When getting a Call for Help from an allied minion or collision, the first minion wave minion that hears it will refuse to sweep its behavior again. This ensures they stay focused on their current target until its death.

Multiple Behavior Shut-offs

All of this specialized logic can be shut off from various game states. If a minion ever targets an enemy champion or hears a call from help caused by an enemy champion, it will reset to default minion AI. If a minion’s target ever dies, it will also reset to non-first minion wave behavior. This ensures that once lane action actually occurs, minions start acting normal again. This rule is especially important to ensure that the Radio Silence rule doesn’t cause minions to chase a champion forever.

Multiple Acquisition Ranges

Unlike the default minion behavior, the first minion wave has three different acquisition ranges: Wake Up Range, Acquisition Range, and First Acquisition Range. These are all used to solve a tricky math problem created by how minions are spawned. Minions are spawned with some time between each one, forming a line with a leading minion. This means that when the leading minion is finally within the acquisition range of an enemy minion, it is very likely the ONLY minion in that range at that time. The long delay on the sweeps (0.25 seconds) can cause more enemy minions to sometimes to be in range when the sweep finally occurs, making the whole thing very unpredictable. Distribute Fire can’t solve this alone if it’s unpredictable whether or not it gets enough minions to check.

Wake Up Range: First wave minions spawn in an asleep state. While in this state, they ignore ALL behavior until directly interacted with or an enemy unit enters their Wake Up Range. It is smaller than the acquisition range.

Acquisition Range: This is as normal (see way way above).

First Acquisition Range: Immediately upon waking up, a minion will try to find its targets in this range instead of the normal acquisition range.

This range is larger than the normal acquisition range. All of these together ensure that minions get a broad array of enemies to then check against its other behaviors for its very first target acquisition.

Walking through this with screenshots should make it more clear.

*The minion hasn’t woken up, even though in this case it would ‘target’ the first minion normally. Even with the ‘first acquisition range’ circle (the white circle), it would only choose between the first two minions.

  • Now that the minion finally has an enemy minion in its wakeup range (the blue circle), it “wakes up” and compares all the minions out to its first acquisition range (the white circle).
  • It discovered the 3rd melee enemy minion has the least number of things targeting it, so it uses that as its preferred target. The opposite happened with that minion, effectively assigning them to each other. From here on only the red ring (and the attack ranges) of the minions really matter. This is the default acquisition range for minions and what every minion after the first minion wave uses always.

Region Avoidance

Following just the General Minion AI Rules, there is nothing to actually keep a minion from following an enemy through the river or jungle, across the map, and into other lanes as long as it keeps its target. In the past this meant you’d experience awkward “minion chase” scenarios through the jungle which finally ended only when the minion lost vision of your champion (most commonly through jungle brush). Since Season 2016, Lane Minions now avoid specific regions of the map. This rule is special because the solution is as obvious as it seems from a problem description standpoint: “Don’t chase into the river!” (or jungle or base perimeter).

Unfortunately, that’s actually not a concept the game had until Season 2015. League of Legends game servers don’t have the models or art that you have when you play.

The server actually sees things closer to this graphic (which is just a visual representation of some numbers it has): The solution we arrived at for this was “...it should just know where the river is.” (Random advice to other game developers out there: it helps to have tools reflect the mental leaps of your players.) So, we added more data to the map. This is what minions now use to figure out things like, “Hey, am I allowed to be here?” There’s a couple subtle rules for this though.

  1. Minions can still attack things when those things are inside regions the minion itself isn’t allowed in. These minions won’t acquire new targets that are already there, however.
  2. Minions will drop all targets when that minion manages to get into the zone, even if that minion is already targeting something. The minion can lock on to Ahri because she’s in an area marked as a lane. (Rule 1) (If Ahri was in the River, the minion wouldn’t be able to target her if it wasn’t already targeting her) It will continue to attack Ahri even when Ahri moves out of lane since it had already acquired her as a target. It will not acquire any new targets in the River however. (Rule 1) Once the minion exits the lane itself, it will drop all targets and refuse to acquire anymore targets until it gets back into lane. (Rule 2) And with these behaviors we can clearly mark some zones minions aren’t allowed in: Jungle. River. Base Perimeter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment