I’m so close to the solution for Danger Valley, looking back at a post from 2019, but I still don’t understand what it wants. Like the guy back in Feedback: Danger Valley, my hero will only cover the first two rows. There were hints on how to solve it in the old thread, but since I’m still pretty new to code, I didn’t understand what they meant.
Here’s my current code:
# Ogres have taken some peasants hostage! # The scouts have given you intel for an ambush. # this.grid holds an array of arrays. # Inside the sub-arrays, 0 is a peasant, 1 is an ogre. # Use this information to setup fire-traps. # Remember the containing array is just an array! # Iterate over all the elements of this array. for i in range(len(hero.grid)): row = hero.grid[i] # Now, row is just another array! # Iterate over all the tiles in this array: for j in row: if hero.grid[i][j] == 1: # Check if the tile at i, j is 1 to build: hero.buildXY("fire-trap", 36 + 6 * j, 20 + 6 * i) # Finally, retreat back to cover. hero.moveXY(29, 55)
I have technically beat the level before, but only by cheating.