i don’t know what is wrong pls help
# Place explosives to clear a passage to the dungeon.
# The mines should form a rectangle with this perimeter.
perimeter = 160
# The bottom left corner of the rectangle.
bottomLeft = {"x": hero.pos.x, "y": hero.pos.y}
# One mine is placed already.
topLeft = hero.findHazards()[0].pos
# So we can find the height of the rectangle.
height = hero.distanceTo(topLeft)
# Find the width. Use the perimeter and height to calculate it.
w = (perimeter - 2 * height) / 2
# First, we need to place a mine in the bottom left corner.
hero.buildXY("fire-trap", bottomLeft.x, bottomLeft.y)
# Put a mine in the bottom right corner.
hero.buildXY("fire-trap", bottomLeft.x + 48, bottomLeft.y)
# Put a mine in the top right corner.
hero.buildXY("fire-trap", bottomLeft.x + 48, topLeft.y )
# Now go to the demolitionist.
hero.moveXY(74, 32)
# Calculate the area of the rectangle to know the charge.
a = height * w
# Say the area of the rectangle to start the explosion.
hero.say(a)
Should be bottomLeft.x + 44 if you want to do it the hard way. You should be calculating the length based on the perimeter though.
Edit: Nevermind. the +44 or +48 can vary. So you have to calculate based on perimeter.
How do i do that @SuperSmacker?
length = (Perimeter - hero.distanceTo(topLeft))/2
still not working @SuperSmacker
You did it wrong. You are supposed to add the length TO the bottomLeft.pos.x, not just dump it there.
Ohhhh (20 chars) Deadpool pls kill 20 chars
this is what happens @SuperSmacker
In your code you defined height as hero.distanceTo(topLeft), and then you defined length as (perimeter - 2 * height)/2, which doesn’t make sense. The height is the width. so delete you width variable and replace the area as height * length. Gosh seriously proofread your code yourself.
The mistakes you make are primitive. Try to find them yourself before blaming me for everything.
But are the placing of the mines are correct?
it’s still not working. Sorry i am getting confused
# Place explosives to clear a passage to the dungeon.
# The mines should form a rectangle with this perimeter.
perimeter = 160
# The bottom left corner of the rectangle.
bottomLeft = {"x": hero.pos.x, "y": hero.pos.y}
# One mine is placed already.
topLeft = hero.findHazards()[0].pos
# So we can find the height of the rectangle.
height = hero.distanceTo(topLeft)
# Find the width. Use the perimeter and height to calculate it.
length = (perimeter - hero.distanceTo(topLeft))/2
# First, we need to place a mine in the bottom left corner.
hero.buildXY("fire-trap", bottomLeft.x, bottomLeft.y)
# Put a mine in the bottom right corner.
hero.buildXY("fire-trap", bottomLeft.x + length, bottomLeft.y)
# Put a mine in the top right corner.
hero.buildXY("fire-trap", bottomLeft.x + length, topLeft.y)
# Now go to the demolitionist.
hero.moveXY(74, 32)
# Calculate the area of the rectangle to know the charge.
a = height * length
# Say the area of the rectangle to start the explosion.
hero.say(a)
Found the problem.
Change length = (perimeter - hero.distanceTo(topLeft))/2 to length = (perimeter - 2 * hero.distanceTo(topLeft))/2.
After that you are all set.
THANK YOU @SuperSmacker it worked!
It also took me a while to figure that out. Never thought of going to the forum at the time.