I can't let these statements pass without comment (I have a cold and I'm grumpy)
Quote: "In the weighting: three 2's would get a score of 16+2 or something, and a pair of aces would get 14+13 and win, which is incorrect."
Use your imagination people. Set the hand scoring high enough to compensate.
Quote: "You need the higher ranked hands to beat the lower ranked hands, regardless of the value of the cards"
The lowest ranking poker hand is the
highest card so card value is a first and foremost necessary check. The value of the cards always should be taken into account.
@That1Smart Guy
Quote: "still, its not the checking for wat cards are in each players "communiy hand" isnt the problem, its checking if a hand is present"
and I know you want this abandoned for now but from the recent comments, there's not a full understanding of what I was trying to convey. The scoring system is the determiner of the hands and vice versa. Though you have to have a hand scoring high enough to compensate for the value of the cards. Each incremental hand could be in values of 200.
Highest card = 0
Pair = 200
2 pair = 400
3 of a kind = 600
etc.
All you need is subtraction to find the hand. That is, the difference between the indivdually sorted cards in the hand. I kept stressing the importance of sorting the player's hand. That's because the sort will put everything in order and help tell you what the player has.
The porcess might go like this:
deal the cards
-texas hold em style: create a hand by filling in the players empty slots (up to 7 right?) with the cards on the table plus the 2 they have.
-sort the players hand
-check the suits - if the same, possible flush
-check highest card - if > 6 then a possible straight
-find the difference between cards (abs(card2-card1), abs(card3-card2), abs(card4-card3), abs(card5-card4) etc if more than 5)
-if the difference is 0, you have 2 of the same cards. If there are two differences of 0 in a row, you have 3 matching cards etc.
if there is a difference of 1 between all of the cards, you have a straight. The high card and the suit check you did earlier will tell you if you have a straight flush of royal flush.
-keeping track of the differences and the card value will spell out your hands. If you had a difference of 0 between card2-card1, and a difference of 0 between card4-card3, then you would have 2 pair. Understand? The differences between the sorted cards tell you the hand, and/or a set of matching suits tell you the hand. So it becomes very important to know the value (1-13) of the card so you can find those differences. Then the value of the hand is added to the card rank : 3 of a kind 5s = 600 + 6
As you find the differences between the cards in the hand, you test what the hand is. Because I'm fading into dizzyness, this example is clunky, but shows the idea. I use the difference between cards with the idea that you would use 1 routine to test the hand as opposed to how I did the test twice - still shows you what's going on:
randomize timer()
dim player(5,7)
rem some random cards - just 7 through 13 for ease
for n=0 to 4
c=rnd(6)+7
player(1,n)=c
next n
rem sort hand
for i=0 to 3
min=i
for j=i+1 to 4
if player(1,j) < player(1,min)
min=j
endif
next j
temp=player(1,i)
player(1,i)=player(1,min)
player(1,min)=temp
next i
rem display values
for n=0 to 4
print player(1,n)
next n
rem card hands
dim match(5,1)
rem check for straight
scount=0
if player(1,4) > 6
for n=0 to 3
if player(1,n+1)-player(1,n)=1 then inc scount
next n
endif
rem we have a straight
if scount=4
handvalue=1000+player(1,4)
print "Straight"
scount=0
end
endif
rem check for other hands
for n=0 to 3
if player(1,n+1)-player(1,n)=0
match(n,0)=player(1,n+1)
match(n,1)=match(n,1)+1
endif
next n
rem display hand value
for n=0 to 4
select match(n,1)
case 1
print "pair of ";match(n,0)
endcase
case 2
print "3 of ";match(n,0)
endcase
case 3
print "4 of ";match(n,0)
endcase
endselect
next n
there's a counting error in the check for hands part, I'm too blind to see it right now so 3 of kind and up may error.
Enjoy your day.