Thread: sequential number test View Single Post
 2012-02-08, 21:32 #6 Bundu     Jul 2004 Mid Calder, Scotland 5·37 Posts axn that function is amazing, thankyou for posting a great off the cuff working example. It is so good it doesn't even need the array to be sorted, is that intentional or a by product of the bitwise operation? Sorry for the questions but as a complete novice in javascript the bitwise functionality is beyond me at the moment! But I have begun studying it! So far I have only learned to count in binary but it is a start! This was my approach so far (just so you know I am actually trying to do some work myself and not just sponging!) which feels positively clumsy compared to yours. My thinking was if I was analysing the hand array I would loop through and at the same time perform counts of the numbers which would allow me to decide if I should check for pairs, trips, quads of full boats. I am only at the beginning but further thinking is laid out below. Code: 

 I saw that http://www.suffecool.net/poker/evaluator.html this chap seemed to have taken the approach that you guys did (working at the bitwise level and hash tables ). Again knowing that this is currently just outside my grasp (and a suspicion that just copying his work with no thought was just plain cheating!) I was thinking that I would try and eliminate possibilities through quick determinations. As the link specifies if all possible hands are included (5 cards) then there are 2,598,960 hand combinations of which there are 7,462 distinct hands. Becuase he went with an elimination approach I thought I *could* do the same but using simpler calculations. My theory was get some quick hits ( I am trying to replace a pass and play poker app I used to have access to on my iphone but is not on android that a buddy of mine and i played every lunchtime!): If the players have the same hands(numerical values) you don't have to compute the numeric values of either hand as we have an instant tie and split pot!*(save calcs). [*However If they have the same hand they could avoid a tie with a flush.] Flush is an *easy* test as there are only 4 suits, flush true breaks tie anything else keeps it the nice thing about this is that although flush mechanics are more complex if the players have the same numerically valued hands the finer flush mechanics can be ignored as they rely on numeric values of cards! If the players don't have the same hand then we need to do a little more work as we need to evalute both hands so in the code above I thought the "repeatArray" would quickly tell me if quads or full boats were possible (don't bother testing for anything below which elminates flushes and below). Check each hand for straights and flushes (eliminate below if found) Then check for trips (elminate below)... and so on I realise now that my approach involves a lot more logic and will possibly be more computationally intensive which is a bad thing! So I will persevere for now with what I can and as I learn the bitwise element I should be able to potentially improve my code later!