Gridmancer Redux – A Guide

Intro

Gridmancer Redux is a tricky level, and if you check the scoreboards, most of the people have empty code! At first glance, it might sound hard, but don’t you worry! I’ll teach you step-by-step on how to crack down this level.

How does it work?

You are given a two-dimensional array, and you must use that given data to place rectangles where it is needed. Hand-placing is not allowed!. So what exactly is a two-dimensional array? Here’s your simple array:
arr = [1,2,3,4]
Here’s a two-dimensional array:
arr2 = [[1,2,3],[4,5,6]]
In our case, instead of numbers, we have a “Wall”, or "Coin:.

First step – Go through the grid

The first step is to iterate in both dimensions to see if we get a Coin or not. First, we must iterate through the “rows”. To do that, you must iterate through the navGrid, the number of elements it has, total. To find the number of elements, you’d use len(), and to repeat that the number of times, we can name our element, i. So here’s what we’ll have:

for i in range(len(hero.navGrid)):
    ...More Code

Then, we must go through the other way, so we can iterate through every single “placement” in the map. To do that, repeat the iteration but the ith element of navGrid. Try to figure it out yourself! Call the second element, j. :slight_smile:

Second step – Finding the coin/wall

After you’ve finished the two for loops, you can now check if the given “searched” element is a Wall, or a Coin. It’s just similar to finding a type of a troop in the array of friends, but with two dimensions. Here’s finding a “griffin-rider” within the array, friends:

friends = hero.findFriends()
for friend in friends:
    if friend.type == "griffin rider":
        More code...

You can also do the same for our case. Check if our i and jth element is a Coin. You can do so by using two elements instead of one. Since navGrid[i] returns another array, we must also find the jth element inside that array. Try figuring it out!

Third step – Placing the rectangles

Now that you have found whether that certain area is a Wall or Coin, you can start placing the squares on the coins! The command to place down a rectangle is hero.addRect(x,y,width,height). The x and y is the center of that rectangle. Remember, a single rectangle can pick multiple coins, use that as your advantage and start Reduxing!

If all goes well, you can finish this level in 27 lines!

Happy coding!

7 Likes

Very detailed explanation, it’s very helpful for the ones who struggles on this level.

2 Likes

Nice. I think these guides are a good plan. Hopefully some people will read these first, before making a topic asking for help. There definitely seem to be some levels which come up again and again…
Danny

4 Likes

I partially made this guide because there’s no hints document in this level, so hopefully this gives some people a “path” to take.

5 Likes

Thank you so much @Chaboi_3000 this has helped me a lot

1 Like

Hey, please don’t revive dead topics.

Yeah Sorry I forgot (20 chars)

Umm @Chaboi3000 how do you place the rectangle without overlapping the wall.