Hero Builds and Counter Picks in Dota 2 With Apache AGE
Tags: gamedev, postgres, opensource, tutorial
Published: 2023-04-12 01:54:50

## Apache AGE

Apache AGE is an extension for PostgreSQL that enables users to leverage a graph database on top of the existing relational databases. AGE is an acronym for A Graph Extension and is inspired by Bitnine's AgensGraph, a multi-model database fork of PostgreSQL. It's basic principle is to create a single storage that handles both the relational and graph data model so that the users can use standard SQL along with openCypher, one of the most popular graph query languages today. 

## What is Dota 2?
Dota 2 is a multiplayer online battle arena (MOBA) game developed and published by Valve Corporation. It is a sequel to the original Defense of the Ancients (DotA) mod for Warcraft III: Reign of Chaos.

In Dota 2, two teams of five players each battle against each other to destroy the enemy team's Ancient, a large structure located at each team's base. Players control powerful hero units with unique abilities and characteristics, and gain experience and gold as they defeat enemy units and structures. This allows them to level up, gain new abilities, and purchase items that enhance their hero's strengths.

The game is played in real-time, and players must work together to coordinate their hero's abilities and strategies to outmaneuver and defeat the opposing team. Dota 2 is known for its high level of strategic complexity and depth, as well as its active competitive scene with numerous professional players and teams competing in tournaments worldwide.

Today we'll learn how to create these builds and analyze which hero is a good match against another with Apache AGE, an opensource graph database extension for PostgreSQL.

## Builds

A build in Dota 2 is a particular combination of items, abilities, and talents that a player selects for their hero. Building the proper equipment, abilities, and talents is essential to a player's success in the game because it has a significant impact on their hero's power and skills.

Here's an example of a build for _Naga Siren_


![Naga Siren Build](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocx62lyr44t06o3sfe42.png)

There are different types of builds in Dota 2, such as core builds, situational builds, and experimental builds. Core builds refer to the standard set of items and skills that most players use for a specific hero, while situational builds are chosen depending on the specific situation and match-up. Experimental builds, on the other hand, are unique and unconventional builds that players may try out to see if they work.

A good Dota 2 build should take into account the player's role, the enemy team composition, and the current state of the game. It should also be adaptable and flexible enough to adjust to changing circumstances in the game. To create a good build, players need to have a good understanding of their hero's strengths and weaknesses, as well as the items and skills available in the game.

## Counter Picks

Counter picks refer to selecting a hero that is particularly effective against one or more heroes on the opposing team. A counter pick is chosen with the intention of gaining a strategic advantage over the opposing team, by selecting a hero that can exploit the weaknesses or vulnerabilities of the enemy heroes.

Counter picking is an important aspect of Dota 2 strategy, as it can greatly affect the outcome of a match. For example, if the opposing team has picked a hero with strong magical abilities, a player may choose to counter pick with a hero that has magic resistance or immunity. Alternatively, if the opposing team has picked a hero that relies on mobility and speed, a player may choose to counter pick with a hero that has disables or slows.


![Hero Picking](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyibt1vjvs14hgmaciab.jpeg)

## Slithice, the Naga Siren

Naga Siren is a versatile hero in Dota 2, known for her ability to control the battlefield with her illusions, disable enemies with her net ability, and reset team fights with her ultimate ability, Song of the Siren. Her primary attribute is agility, which means she excels at dealing physical damage and has a high attack speed. She is typically played in the carry role, but can also be played as a support or utility hero.

She is a strong hero that requires good game sense and strategic thinking to play effectively. She is often picked in professional matches and can be a formidable force in the hands of a skilled player. So, let's create our graph and add her to it.

```sql
-- Create the graph.
SELECT create_graph('dota');
NOTICE:  graph "dota" has been created
 create_graph 
--------------
 
(1 row)

-- Add Naga Siren to our graph
SELECT * FROM cypher('dota', $$
CREATE (a:Hero {name: 'Naga Siren', abilities: ['Mirror Image', 'Ensnare', 'Rip Tide', 'Reel In', 'Song of the Siren']}
RETURN a 
$$) AS (Hero agtype);

                                                                                     hero                                                                                     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {"id": 844424930131969, "label": "Hero", "properties": {"name": "Naga Siren", "abilities": ["Mirror Image", "Ensnare", "Rip Tide", "Reel In", "Song of the Siren"]}}::vertex
(1 row)
```

## Items and Abilities

Naga Siren is renown to be one of the most boring carries to play against. She will never put herself in harm's way, instead pushing one or more lanes at once thanks to _Mirror Image_ while she will be farming the jungle. Because the illusions keep the lane pushed to provide vision and map control, enemies will have trouble ganking her without using _Smoke of Deceit_. Furthermore, _Song of the Siren_ either allows her to run away or wait for her team to react if enemies have not bursted her down quickly enough.

Now about the items you should consider purchasing. As a carry Naga Siren, you should almost always go for _Radiance_ as your first major item. However, do not forget to buy enough cheap and cost-efficient items to fill your slots like _Wraith Band_ or _Infused Raindrop_. Then, go for _Boots of Travel_, _Manta Style_, and _Octarine Core_ to constantly produce illusions and _Rip Tide_, pushing out all the lanes and razing jungle camps. Finally, consider choosing between _Butterfly_, _Heart of Tarrasque_, _Diffusal Blade_, or _Eye of Skadi_ to increase survivability and damage output of Naga Siren and illusions, applying constant pressure on all lanes to limit opportunities for enemies to make plays as they will have to defend nonstop.

As for your ability build, you can opt for an early value point in _Ensnare_ if you want some disable to produce kills with teammates. Otherwise, focus entirely on _Rip Tide_ and _Mirror Image_ so you can use them for farming lanes and jungle camps.

```sql
SELECT * FROM cypher('dota', $$                                                              
MATCH (a {name: 'Naga Siren'})                                                                      
CREATE (a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Radiance'}),                                         
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Wraith Band'}),                                             
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Infused Raindrops'}),                                       
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Boots of Travel'}),                                         
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Manta Style'}),                                             
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Octarine Core'}),                                           
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Diffusal Blade'}),                                          
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Eye of Skadi'}),                                            
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Butterfly'}),                                               
(a)-[:RECOMMENDED_ITEM]->(:Item {name: 'Heart of Tarrasque'),
(a)-[:RECOMMENDED_CARRY_BUILD]->(:Build {type: 'Carry', Q: [1, 3, 5, 7], W: [11, 13, 14, 16], E: [2, 4, 6, 8], R: [9, 12, 18]})                                                                       
$$) AS (a agtype);
```

## Counters

Depending on which heroes the enemy team has chosen, Naga Siren will be a good option or a bad option. Let's analyze three cases for each situation.

**Good Against:**

_Arc Warden_
* Song of the Siren stops Arc Warden from acting and allows Naga Siren's team to close in on him, past his  Magnetic Field.
* Mirror Image dispels  Flux. The illusions created from it also disable the slow from Flux if Arc Warden casts it after Mirror Image.
* Arc Warden's playstyle heavily favors split-pushing, which Naga Siren can compete against with her illusions.

_Crystal Maiden_ 
* Mirror Image can dispel Frostbite.
* Song of the Siren can stop Freezing Field regardless of any kind of invisibility as well as allow Naga Siren's team to quickly close the gap on Crystal Maiden.
* Ensnare allows Naga Siren and her team to quickly catch up with Crystal Maiden and kill her.

_Sniper_
* Ensnare with her attacks allows Naga Siren to gank Sniper easily.
* Rip Tide removes Sniper's very little armor.

**Bad Against:**

_Axe_
* Axe will destroy her illusions by proccing  Counter Helix more often due to him being hit by more attacks.

_Gyrocopter_
* Flak Cannon and  Call Down can easily clear Naga Siren's illusions.

_Leshrac_
* All of Leshrac's abilities, especially  Pulse Nova, can easily deal with Naga Siren's illusions.

```sql
SELECT * FROM cypher('dota', $$
MATCH (a {name: 'Naga Siren'})
CREATE (a)-[:GOOD_AGAINST]->(:Hero {name: 'Arc Warden'}),
(a)-[:GOOD_AGAINST]->(:Hero {name: 'Crystal Maiden'}),
(a)-[:GOOD_AGAINST]->(:Hero {name: 'Sniper'}),
(a)-[:BAD_AGAINST]->(:Hero {name: 'Axe'}),
(a)-[:BAD_AGAINST]->(:Hero {name: 'Gyrocopter'}),
(a)-[:BAD_AGAINST]->(:Hero {name: 'Leshrac'})
$$) AS (a agtype);
```

Here is how our graph currently looks in AGE Viewer:

![AGE Viewer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ktgs93njzz0fpb6b1dsf.png)

## Retrieving the Data

Now that we have some information about Naga Siren, her recommended build for a carry type gameplay and the heroes she is good and bad against, we can analyze if she appears as a good option when an opponent chooses a hero. As an example, let's suppose the opponent chose _Sniper_ and then in another game the opponent chose _Axe_. We can visualize all the good counter picks with the following query:

```sql
-- Good options.
SELECT * FROM cypher('dota', $$                                                              
MATCH (a)-[:GOOD_AGAINST]->(b {name: 'Sniper'})                                                     
RETURN a.name                                                                                       
$$) AS (counter_pick agtype);

 counter_pick 
--------------
 "Naga Siren"
(1 row)

-- Bad options.
SELECT * FROM cypher('dota', $$                                                              
MATCH (a)-[:BAD_AGAINST]->(b {name: 'Axe'})                                                     
RETURN a.name                                                                                       
$$) AS (bad_pick agtype);

   bad_pick
--------------
 "Naga Siren"
(1 row)
```

If we had more heroes, then it would be more interesting to see all the available options for a match against _Sniper_ and which heroes not to pick agains _Axe_. Also, it would be best to add each role of our heroes, like _Carry_, _Nuker_, _Initiator_, and so on...

## Conclusion

We demonstrated how to create a graph for heroes and explored their abilities and items. We also explained how hero builds and counter picks work in Dota 2, and why they are important for players to master.

Overall, Apache AGE is an excellent tool for Dota 2 players who want to take their game to the next level. It enables them to create complex graphs that capture the nuances of hero builds and counter picks, and provides them with valuable insights that can help them make better strategic decisions in the game.

For more information on Apache AGE, checkout their [website](https://age.apache.org) and [GitHub repo](https://github.com/apache/age).