i'm trying to develop this very rudimentary dice game in java that gives the player five values (out of 6 from a dice) at random and then do scoring based on what values their dice have.
i'm using standard poker hands like pair/three of a kind/two pair/full house (pair and a three of a kind)/ double (two pairs) / four of a kind / five of a kind / straight (1,2,3,4,5/2,3,4,5,6).
i'm having problems trying to figure out algorithms for these except for five of a kind as that was easy.
for the others i was thinking of sorting the array first by using sort(face_values); then trying to figure out if there's a score there.
what i want to know is when i sort the array using the sort method does it actually move the values around.
ie if i have an array like this
will sort make it like this?
what would be the best way to check for these combinations?
i'm using standard poker hands like pair/three of a kind/two pair/full house (pair and a three of a kind)/ double (two pairs) / four of a kind / five of a kind / straight (1,2,3,4,5/2,3,4,5,6).
i'm having problems trying to figure out algorithms for these except for five of a kind as that was easy.
Code:
if(face_values[0] == face_values[1] && face_values[1] == face_values[2] && face_values[2] == face_values[3] &&
face_values[3] == face_values[4]){
System.out.println("FIVE OF A KIND!!!!!");
}
for the others i was thinking of sorting the array first by using sort(face_values); then trying to figure out if there's a score there.
what i want to know is when i sort the array using the sort method does it actually move the values around.
ie if i have an array like this
Code:
a[0] a[1] a[2] a[3] a[4]
3 4 6 2 4
will sort make it like this?
Code:
a[0] a[1] a[2] a[3] a[4]
2 3 4 4 6
what would be the best way to check for these combinations?
Last edited: