Fun video: me beating Sarven Treasure difficulty 6


#1

Check it out (using Naria’s hide ability, the Sparkbomb, and some fun code to dodge the razor discs, plus a quick flag every now and then):


What does it mean a Hard Execution Limit of 1000000 exceeded?
Sarven Sentry and flag levels in general
#2

Sweet!!

Questions (mainly because of the troubles I have)

Language?
if move() boots:
–What glasses? (I’m thinking about dumbing down my glasses to have less things to process)
–What are you processing? (as in coins/missiles/enemies or just “closest”)

I guess it is time to stop killing the headhunter and instead dodging his sputum


#3

Wow, Nick, that’s awesome! I may be inspired to try cracking another level or two.

Maybe we can get some others, like Glacian, to post a vid or two. :smile:

LOL, that was my thought exactly.


#4

Haha, well, it’s still necessary to kill most of the headhunters as it gets harder, or there’s too much, uh, “material” in the air.

I usually play in Python. I would play in CoffeeScript, but the error handling and nested loops work better in Python.

I’m using the best glasses, but all you really need is any of them that have findEnemyMissiles. The code will actually run fastest with the Twilight Glasses, because it doesn’t have to do any distance or line-of-sight checks when determining who you can see, but if you had short-range glasses you might have fewer enemies to check in your code if you’re doing a lot of processing per enemy in a loop.

I’m looking at coins, missiles, and enemies, yeah, and not just the closest of each. I’m also looking at flags and walls (well, I have some code that pushes me away from the boundaries of the level, not individual walls). I actually don’t have any code for dealing with the teleporters, so the fact that my hero sometimes goes through them is just coincidence.

I don’t want you guys to see what Glacian is doing, because it’ll give you too many ideas and then I’ll have to start nerfing stuff.


#5

Anybody care to share some hints or strategies for the levels 3 and up? I’m a free player, so no fancy skills or spells available…


#6

I managed to pass Sarven Treasure 5 on a free account yesterday.
I used a level 31 Tharin with notable equipment:

  • Best chestplate and shield, good helmet => 3000+ health
  • Emperor’s Gloves
  • Ring of speed
  • (I didn’t use a sword - too slow and short range, unfortunately)

I got the gems by passing all the free levels plus some adventurer levels.

My strategy:

  • Collecting the nearest coin that was not nearer to the nearest enemy (weird but it worked well enough)
  • if no such coin, move to the nearest cross
  • also manually moving around using flags
  • If chain-lightning ready, use it on nearest headhunter

A difference between difficulty 4 and 5 was I had to add an additional strategy to pass 5:
I noticed that if I shielded before getting hit by a razor disk, I would take less damage in the long run. (Works best if you have high shield percentage) Previously, I was ignoring the razor disks but they become a significant obstacle at difficulty 4 and above. I think Tharin is too slow to dodge razor disks so I didn’t try that.
My shielding strategy was not great because it didn’t take into account the velocity of the razor disks but it worked well enough to pass difficulty 5. Having high health also compensates for bad strategy to some extent.

When I tried difficulty 6 there were just too many razor disks to be dodging or shielding from. I need to somehow kill those headhunters early on. This could be difficult with a short-range hero like Tharin but I do have Emperor’s Gloves and Kithgard blade though.


#7

Can we find the nearest coordinate in a list? For example, it I were to store the coordinates of the teleports in a list teleports, can I say teleport = findNearest(teleports)?


#8

I stored the coordinates of the four crosses in an array.
teleport = self.findNearest(crosses) actually worked for me which means findNearest() can also be used to find the nearest position in an array of positions.


#9

Huh. My character just walked into the wall when I tried that. Also, the coin.findNearestEnemy() doesn’t seem to work. I know it has one though, I’ve checked the editor.


#10

I wrote my own function for finding the distance between two positions. (finding distance between two coordinates on a cartesian plane)
And for simplicity, I checked the distance between the coin and the enemy nearest to Tharin, not the enemy nearest to the coin. These enemies were probably the same in many cases though.


#11

@ChronistGilver While coins do have a findNearestEnemy, it doesn’t work because coins do not have a superteam property (I think).


My strategy mainly involved calculating “gravitational forces” between coins as well as enemies and razors. (This is somewhat advanced-ish and not the most optimal though, because part of it requires guessing. No flags, though!)

Basically the gravitational force between two “masses” is GmM/r^2, where G is a constant, m and M are masses, and r is the distance between the two masses. For practical purposes I can just set G=1, as well as the mass of my hero to 1. And since force is a vector, I can just Vector.add these forces up, which will then tell me which direction to go towards.

The hard part is guessing the mass of a target. For coins I use coin.value, but for enemies and razor rings and walls I just picked some smaller negative numbers. (Negative “mass” moves me away from the target, but since gravity only pulls, technically this behaves more like charges.)

If you want to see an implementation just look me up on the high scores thing. Only level 4, though.


#12

As @zuf already answered, yes. Here is the detailed answer:

# list the teleports with coordinates:
targetPositions = [ {"x": 10, "y": 20}, ... ]
# ...or as vectors:
targetPositions = [ Vector(10, 20), ...]

# then find the nearest one:
target = self.findNearest(targetPositions)
# and go towards it:
self.move(target)

(taken from this topic)


#13

I believe you could use the Vector commands to easily define the distance:

distance = Vector.distance(coin.pos, enemy.pos))

Note: I do not have the Programmaticon V (yet), so I cannot check if this is the correct format, but you get the point…


#14

@nick, this is my code:

def Vector(goalPos):
    goalPoint = Vector(goalPos)
    # This creates a vector that will move you 10 meters toward the goalPoint
    # First, create a vector from your hero to the goal point.
    goal = Vector.subtract(goalPoint, hero.pos)
    # Then, normalize it into a 1m distance vector
    goal = Vector.normalize(goal)
    # Finally, multiply the 1m vector by 10, to get a 10m long vector.
    goal = Vector.multiply(goal, 5)
    
    # To avoid the yaks, if you get within 10 meters of a yak, you should vector away from it.
    enemy = hero.findNearest(hero.findEnemies())
    
    if enemy:    
        distance = hero.distanceTo(enemy)
    if enemy and distance < 15:
        # First, make a Vector from the yak to you
        v = Vector.subtract(hero.pos, enemy.pos)
        # Now use Vector.normalize and Vector.multiply to make it 10m long
        v = Vector.normalize(v)
        v = Vector.multiply(v , 5)
        Vector.subtract(goalPoint, hero.pos)
        # Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
        goal = Vector.add(goal, v)
        pass
    mis = hero.findNearest(hero.findEnemyMissiles())
    if mis:    
        distance = hero.distanceTo(mis)
    if mis and distance < 4:
        # First, make a Vector from the yak to you
        v = Vector.subtract(hero.pos, mis.pos)
        # Now use Vector.normalize and Vector.multiply to make it 10m long
        v = Vector.normalize(v)
        v = Vector.multiply(v , 5)
        Vector.subtract(goalPoint, hero.pos)
        # Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
        goal = Vector.add(goal, v)
        pass
    # Finally, determine where to move by adding your goal vector to your current position.
    m = Vector.add(goal, hero.pos)
    hero.move(m)


def findOptimalCoin(coins):
    optimal = -1000
    thione = None
    enemy = hero.findNearestEnemy()
    
    for coin in coins:
        if coin.value / hero.distanceTo(coin) > optimal and hero.isPathClear(hero.pos, coin.pos):
            if enemy and hero.distanceTo(coin)<hero.distanceTo(enemy):
                optimal = coin.value / hero.distanceTo(coin)
                thione = coin
    return thione

while True:
    coins = hero.findItems()
    coin = None
    coin = findOptimalCoin(coins)
    #coin = hero.findNearestItem()
    if coin:
        Vector(coin.pos)
    

When I try it, my computer just freezes. What should I do?


#15

First thing to try would be to not call your method Vector, since that would conflict with the builtin Vector name. Any better?

Also, don’t use isPathClear here, since it’s kind of slow, and it doesn’t check whether enemies obstruct it, just traps or walls (which is never the case here).