Checking Integers for Dice Game

Hi guys,

Im trying to make a dice game and already setup a mechanic which randomly generates 6 different number and checks for the ones which adds to the score.

Now i wanted to add the mechanic to check f.e. a street (1,2,3,4,5,6), which i thought of solving so:


Made an Array which includes 1,2,3,4,5,6 and check for identical…(Don´t know if its working because it never came when playtesting but it should, or am i wrong?)

Now i want to also check for 2 times 3 same numbers. F.e. 1,1,1,3,3,3 or 4,4,4,6,6,6
and after that checking for 3 times 2 same numbers like 2,2,3,3,5,5.

How could ich check that in the easiest way? Couldn´t find anything online and the only way i could think of was to manually check every possible combination which would take a huge amount of time to setup for.

Thanks in advance.

I tried to implement it myself (manually), or how i thought it should work, but it sadly does not.
This is how i thought i could Check for the specific case if there is exactly 1,2,3,4,5,6 after the diceroll.

I know i could do it like this and just compare all the integers for the same value…

But in the next step i want to check those values for 3x2 different numbers,( f.e. 11,22,33 or 55,11,33) and i think to do it the way like in the picture above will take a huge amount of time and there should be an easier way to do it.

This is how i thought i could use Arrays?
What am I doing wrong?

Help would be much appreciated! :slight_smile:

Hi!

The reason why your check for identical didn’t work is that you’re checking specifically for the array “1-2-3-4-5-6”, meaning that the rolls “3-4-2-5-1-6” won’t be accepted since they’re not in the same order, even though all the values are the same.
While this could be solved by reordering the Rolls array, it wouldn’t help much for the next steps.

I took a shot at the problem and found a potential solution by counting how many of each number appears in the rolls.
Here’s the code that you can copy and paste (though you need to adapt it to your architecture).

LocalNumberRepartition and ReorderedRepartition (choose better names than I did) are Local Variables, while DiceToAnalyze is the input to the overall function (you can take all your Dice 1 to Dice 6 and put them in an array).

I left an empty Function call for the array reordering, but I’m sure you’ll find online how to reorder an int array in Blueprints even though there is no single node to do that as far as I am aware.

By continuing the chain of Branches, you should be able to test for pretty much any scenario you’d like, including if 4 dice are equal or even all 6.

Good luck on your project!

1 Like

Here is another take:

They array length can help filter the conditions:

  • 1,1,1,3,3,3 or 4,4,4,6,6,6 will be in a length of 2.
  • 2,2,3,3,5,5 will be of 3.

The function:

Multiplying the value of the map will filter the combinations:

  • 2,2,3,3,5,5 → 2 * 2 * 2 = 8
  • 1,2,3,5,5,5 → 1 * 1 * 1 * 3 = 3