# How do I find a group of enemies around area?

I’m doing giants gate, and I’m seeing top rankers use fireball for groups, and lightning for 1 enemy alone. I’m wondering how to find groups around an area? Is there a code to find that?

1 Like

1. They have an algorithm that uses a list of enemies and compares each enemy’s distance to the last enemy, sorts the closest ones into a list, and throws a fireball to at least one of them. (Man, that’s one complicated algorithm !)
2. Maybe they have recognised where most of the units are close together and then they throw a fireball there. (This one is much more likely as I have seen this in the Infinite Inferno video on the CoCo Esports website )

Thanks, but what do we use or what command do we use? Is there a sample?

@Coder3 check on the methods bar there youll find i’ve just search in the methods bar and i know how to do that

Which methods bar? Where?

Where in methods bar?

Methods chasss 2000000000000

here

if you click the code you can see the snippet

Time? I believe I used time in my code. I changed my code once 2 minutes was up to spawn throwers in enemy base cuz the giants were dead.

its an example of the methods

Of which code? Vector?

@Alfa_Jayden_Iskandar Is it in vector? Which sample code?

Sorry, I don’t play Giants Gate, but what do you want to achieve?
In Vector tab only this is useful:

Maybe you want this? /

``````
function findByProximity(v, d){
let proxyArr = [],
items = hero.findItems();
for ( let len = items.length -1, i = 0 ; i < len ; ++ i )
if (items[i].pos.distance(v) < d)
proxyArr.push(items[i]);
return   proxyArr;
}

// or
// let findByProximity = (v, d) => hero.findItems().filter(item => item.pos.distance(v) < d);

let items = findByProximity(Vector(42, 45), 15));

// or python
// rewrite the function with append for python or use
// findByProximity = lambda v, d: [item for item in hero.findItems() if item.pos.distance(v) < d]

// this is direct copy/paste from another level.
``````

Replace items with enemies and findItems with find Enemies.
filter is explained here:

Modifying this pattern you can make many things:

Is that in Javascript? I’m currently using python tho.

@Coder3 its on methods in the unit one wheres like thers `unit.maxSpeed` and so on

Python’s version of filtering

``````sel = 'thrower'
filteredList = filter(lambda f: f['type'] == sel, hero.findEnemies())
``````

I think the biggest problem is getting the fireball to hit.
Without access to the enemies’ heading and speed, it is difficult to know where they will be by the time the fireball lands haha…

1 Like

Wow, you’re eleow! Top 10 giants gate!

Btw my codecombat username is robot317, I’m in top 15.

Wow you are top 10 now too!
Btw, love your rip-off of Giant’s Gate. Summoner opens up lots more possibilities and strategies. If only more people know about it