![]() |
#11
|
|||
|
|||
![]()
Btw- I think this line is wrong.
while(random1 == (random2 || random3 || random4 || random5)) If you still have a chance to drop this class, you probably should. I think you are in way above your head. |
#12
|
|||
|
|||
![]()
[ QUOTE ]
what i am struggling with is that how will one card ever equal the other since each element of the array is the number and suit of the card [/ QUOTE ] use (indexOf(card)+1)mod13 to get rank. use math.floor(indexOf(card)+1)/ 13)) to get suit. Or something like that. And I'm not sure if you random process is the best, or even if it will work. |
#13
|
|||
|
|||
![]()
lol tom little late for that. school ends in 2 weeks and this is the last project of the year. ive gotten As in the class, but this one is tough. and no i do not plan on pursuing computer programming in the future lol
|
#14
|
|||
|
|||
![]()
[ QUOTE ]
And I'm not sure if you random process is the best, or even if it will work. [/ QUOTE ] http://en.wikipedia.org/wiki/Shuffli...ing_algorithms |
#15
|
|||
|
|||
![]()
An optimal shuffling algorithm is to take an array of 52 integers from 0 to 51 representing the cards. Since you only need 5 cards, you can shuffle 5 cards deep.
For the first card, pick a random number (x) between 0 and 51. Swap array element 0 with element x. Then pick a number (y) between 1 and 51. Swap array element 1 with y. Continue this 3 more times and you will get a true shuffle for 5 cards with minimal work. This is explained in the article, but you only need to go 5 deep for this project. |
#16
|
|||
|
|||
![]()
hey all, i have figured out how to do it! I think this is sort of what people were telling me. I believe it's called modulo, or something like that. if the remainders of the random number divided by 13 are equal then they are the same rank.
Quads if(random1%13==random2%13 && random 2%13==random3%13 && random3%13==random4%13 || random1%13==random2%13 && random 2%13==random3%13 && random3%13==random5%13 || random1%13==random2%13 && random 2%13==random4%13 && random4%13==random5%13 || random1%13==random3%13 && random 3%13==random4%13 && random4%13==random5%13 || random2%13==random3%13 && random 3%13==random4%13 && random4%13==random5%13) { alert("You got quads!"); } and then else if for the rest of the hand rankings |
#17
|
|||
|
|||
![]()
The method you describe here are a lot easier if you just count up how many "pairs you have. Compaare 1 to 2 3 4 5, 2 to 3 4 5, 3 to 4 5, 4 to 5, and see how many pairs you get.
count = 0; if (random1%13 == random2%13) count++; if (random1%13 == random3%13) count ++; .... if (random4%13 == random5%13) count++; if (count==0) alert("you have high card, a straight, or a flush, or a straight flush"); if (count==1) alert("you have a pair"); if (count==2) alert("you have two pair"); if (count==3) alert("you have three of a kind"); if (count==4) alert("you have a full house"); if (count==6) alert("you have quads"); |
#18
|
|||
|
|||
![]()
EDIT: I AM RETARDED
realized it should be if(random1 >=0 && <=12 && random2 >=0 && <=12 && random3 >=0 && <=12 && random4 >=0 && <=12 && random5 >=0 && <=12) it works now! the problem with that tom is i need to do flush. i just did it my way. its a lot of typing but very easy. i've got quads, trips, two pair and pair working. im trying to do flush now. do you have any ideas? i tried if(random1 >=0 || <=12 && random2 >=0 || <=12 && random3 >=0 || <=12 && random4 >=0 || <=12 && random5 >=0 || <=12) but that didnt work. it just said everything was a flush |
#19
|
|||
|
|||
![]()
[ QUOTE ]
Btw- I think this line is wrong. while(random1 == (random2 || random3 || random4 || random5)) If you still have a chance to drop this class, you probably should. I think you are in way above your head. [/ QUOTE ] why is it wrong? the while statement makes it so that the same card won't show up twice. i have all the hands done. now i gotta add the betting. here's what i have so far. http://dan.122blue.com/ |
#20
|
|||
|
|||
![]()
(random2 || random3 || random4 || random5) will evaluate to 0 or 1. You need to use something like
while((random1==random2) || (random1==random3) || (random1==random4) || (random1==random5)) |
![]() |
|
|