I'm making a dice game. There are 5 dice in which I have all the values for and I need to determine if they make up a full house (3 of one and 2 of another), small straight (1-4, 2-6 or 3-6) or a large straight (1-5, 2-6).
Perhaps the best way to approach this seems to be to use regular expressions.
Does anyone know how I would go about representing these rules in regex?
Or if you can provide a better solution, I'd appreciate that.
Examples:
Edit
Changed wording to highlight that this is my inexperienced opinion.
I know how to achieve this using code, but it seems like such a long winded solution, I'm wondering if there's a more simplistic approach.
I would order all the numbers decreasing and then do some linear criteria matching on each value as you go along it whether it be in an int[] or a string.
Don't know about c#, but in a scripting language I'd take the regexp route. For each side, calculate how many times it occurs in the combination and join the results together. For example, for the combination 12342
the counter string will be 121100
. Then match the counter string against these patterns:
/5/ = Five of a kind /4/ = Four of a kind /20*3|30*2/ = Full house /1{5}/ = Large Straight /[12]{4}/ = Small Straight /3/ = Three of a kind /2[013]*2/ = Two pair /2/ = One pair
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With