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/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
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.