Wasn't sure how else to word the title. I made a yahtzee game, simple enough. But I think the code could be done better. Right now, each category has it's own code for checking the dice to see if they match the requirements. It's cumbersome and I don't like it.
I'm trying to think of a way to take the numbers from the 5 dice and somehow run a pattern filter over it to see if it meets the category's criteria, if that makes sense.
Perhaps forming a binary string from them. For instance, my string for 5 dice number 1 through 5 would look like this:
0000000100000010000000110000010000000101
Then I could overlay a filter or pattern of what I'm looking for, whether it be only 4's or a full house. Function would give me a simple yes or no if it matches the pattern. I have no idea if this is possible without regex but thought I'd see if any of us can come up with something.
"I like offending people, because I think people who get offended should be offended." - Linus Torvalds