Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Applying filters to a set of numbers?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jul 2016 19:57
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
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Jul 2016 08:49
Yahtzee outcomes and optimisation are extremely calculatable, but also quite complicated. Try this for starters...

http://www.csc.kth.se/utbildning/kth/kurser/DD143X/dkand12/Group5Mikael/final/Markus_Felldin_and_Vinit_Sood.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-11-25 03:37:45
Your offset time is: 2024-11-25 03:37:45