Download

Need some help with my foreachloop "debug" system

Hi everyone!

I’m currently developing a small, simple game that consist basically in an hexagonal grid and 5 different terrain tiles that can be placed on it. Each terrain has a value which can be positive or negative. You win the game when the sum of the tiles equals zero.

https://preview.redd.it/lb57kq50fkq61.png?width=1234
I’m trying to build a development tool that can calculate every possible tile combination that gives me a zero sum and right now I’ve put 4 ForEachLoop in a row (current grid is 2x2) with a structure array that contains each tile and their current value.

https://preview.redd.it/3ual2993fkq61.png?width=571

https://preview.redd.it/tsfwjfa4fkq61.png?width=1569

https://preview.redd.it/abv7io6nfkq61.png?width=633
This works fine but since I’m planning to have bigger grids (4x4, 6x6 etc) I was wondering if there’s an easiest solution rather than putting tons of eachloop in a row considering that I’m aware of the number of my grid’s tiles.

I’m sure it’s easy but I can’t grasp the solution right now :smiley:

Thank you for all the help that you can give me!

I think you could be adding it up wrong. Those loops are calling each other recursively. Maybe what you want is each successive loop on the completed pin of the previous.

How come one loop doesn’t do the trick?