Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

[Solved] Help understanding the math in Cubic Minefield


Ok so I’m usually really good at math and usually able to understand it very quickly and efficiently but this level makes no since to me. I made it through the level finally but I don’t understand all the math behind it. I hate asking this but can someone please translate it into very understandable terms and break it down for me. I looked through all the other posts I could find on this level but some just left me with more questions than answers and the others didn’t help me to understand it. Any help is greatly appreciated.


“y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)” See that line in the while true loop in the level? That’s a cubic equation that describes the hero’s path.

The a, b, c, and d are the coefficients of the x^3, x^2, x, and the constant, respectively. They are given by the tower.a, tower.b, tower.c, tower.d

If you want to know why this works:

while True:
    # To find the path use a cubic equation
    y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)
    hero.moveXY(x, y)
    x = x + 5

It makes the hero move step by step along the path of the cubic equation. The hero takes a step toward (x, y), then the hero increase x by 5, plug it into the cubic equation again, and move to the new position, and keeps going until the hero reaches the exit.

Does that answer your question?


I think I’m starting to get it a little but I’m still a little confused. Correct me if I’m wrong but is the y point inside the equation the times (3,2,1,0). If so that makes a bit more since. The other thing that doesn’t make much since is the functions mult and power are only defined but I don’t see them being used. In my programming experience (which is very little I’ll admit, and its from JavaScript and C++ not Python which is what I’m using) you have to reference it somewhere in the code to use it just defining it does nothing. Now its possible I’ve missed where it was reference but then I’ve missed it dozens of times.


It does use the power function that it previously defined, and within the power function it uses the mult function.


Right sorry I see the power function I’m having trouble focusing sometimes. But the mult function I don’t see. Is it the * in the *= part.


You’re supposed to use the mult function in the power function (can’t post the code since no solutions)

With the same format as the code in the mult function.


total *= number This is what I have under the power function.


Yeah. You were supposed to use the mult function. Not *= (I used total = number ** exponent. Pretty sure no one did it the way it’s intended to be xD)


Ok then so did I just happen to find a back door so to speak. Also so I understand the way it was supposed to be could you message me the way it was supposed to be. I already got past the level but I always like seeing other ways to do it and pick out my own that I like. Just the power function part is fine.


Sent. Hopefully that helps! :smiley:


That helps a decent bit. Thanks now I’m just going to have to study it more but it does help.
One last question its a bit unrelated but is there a place on the internet that says more about the parameters for items and enemies cause I want to reference them for certain other levels but I don’t know what some are such as it took me a while to find potion and how to tell the types of enemies such as thrower caster ect.

BTW thanks again.


You want to loop through the enemy and find all the enemies of one type?

Use a for loop

def findDangerous():
    dangerous = []
    for enemy in hero.findEnemies():
        if enemy.type == "warlock":
    return dangerous


@SuperSmacker Thanks but that doesn’t completely answer my question. Its more about a list of names for the different items and enemies so when I make (and undertand) arrays, for say dangerous( basically I didn’t even know there was a warlock type.
Ex: coins are called coins with bronze having value of one, silver is two…
Ex2: enemies there are throwers, casters, munchkins ect.


If you want to see what type an enemy is you can tap on it and it says their specific name and their type.


I’ve tried tapping on them and it hasn’t worked for me. Is it only available after the desert cause I’m stuck in the desert.


Coins value is item.value.

Enemy’s type is enemy.type

Believe me warlocks are nasty. They shoot magic missiles, summon skeletons, cast grow (4x power), and they explode when they get killed.


I get how to get the types and all. Its just I wish there was a list that said what all different types there are like a list that says list of all items are coins, potions, mushroom, ect. and list of all different enemy types is munchkin ogre warlock ect.


Oh just go to level editor and look at the drop down menu to the right. It shows all the thangs there could be, including items, troops, and other stuff.


Awesome thanks… Wait did they just change the skins of some of the items in Spring Thunder. Lol they tricked me.