
-----------------------------------
person
Mon Jan 31, 2005 12:35 pm

a = 3 values out of 5 values
-----------------------------------
i was wandering if ther was a command that does this

if (a= 3 out of the 5 values) then

-----------------------------------
Tony
Mon Jan 31, 2005 12:57 pm


-----------------------------------

for i:1..5
     ...

 :lol:

-----------------------------------
person
Mon Jan 31, 2005 2:26 pm


-----------------------------------
can u elaborate? cuz i dont understand

-----------------------------------
Tony
Mon Jan 31, 2005 3:11 pm


-----------------------------------
actually what you can do is..

take your 5 values and sort them to be in order. Now for the condition to be true, a would equal to the 3rd and ether 1st or 5th.


sort(values)
if (a == values

-----------------------------------
md
Mon Jan 31, 2005 3:13 pm


-----------------------------------
in psudo code...

int good_count = 0;
for i = 0 to 5 do
    if test[i] == true
        good_count++;

if good_count >= 3
    // this is where your code goes


you can also do it without a loop:

int good_count = 0;
if cond_1
    good_count++;
if cond_2
    good_count++;
if cond_3
    good_count++;
if cond_4
    good_count++;
if cond_5
    good_count++;
if good_count >= 3
    // your code


-----------------------------------
person
Mon Jan 31, 2005 3:20 pm


-----------------------------------
so i have to type that so many times?   :(  :(  (im making holdem, and i want to check for a 3 of a kind)

-----------------------------------
md
Mon Jan 31, 2005 3:28 pm


-----------------------------------
how do you store cards? There are lots of ways to simplify card functions, depending on how you represent a card. However, I must point out that the code above is fairly simple and short...if you're going to complain about 15 lines then I'm not sure how your going to write any actual programs...

-----------------------------------
1337_brad
Mon Jan 31, 2005 6:44 pm

Erm..
-----------------------------------
What if you save all the cards to an array, and then check the array for 3 cards... D: seems efficiant.


var Player1hand : array 1..5 of int   % 5 cards in the players hand
var HowManyOfEach: array 1..13  of int % 13 possible cards in the hand %(ace-king)
%put code here to get the values to the array

for i: 1..5
     HowManyOfEach(Player1hand(i)) += 1  % this adds one to the occurance %of cards array for whatever card is in the players hand
end for

if HowManyOfEach(1) > 3 then
%code for 3 of a  kind aces
elsif HowManyOfEach(2) > 3 then
%code for 3 of a kind twos, and just repeat this code for all the hands..
[/code]
