Skip to content

Instantly share code, notes, and snippets.

@syuhei176
Created November 22, 2018 07:26
Show Gist options
  • Save syuhei176/7511684d82c8c10e4512b475c21d30db to your computer and use it in GitHub Desktop.
Save syuhei176/7511684d82c8c10e4512b475c21d30db to your computer and use it in GitHub Desktop.
porker
function oddsCal(bytes52 a)
internal
pure
{
bool r3 = false;
uint8 r2 = 0;
for (uint i = 0;i < 13;i++) {
uint8 r = (a & (0x8004002001 << i));
if (r >= 3) {
// 3 card
r3 = true;
} else if(r >= 2) {
// pair
r2 += 1;
}
}
bytes13 s = (a & (0x1FFF)) | (a & (0x1FFF << 13)) | (a & (0x1FFF << 26)) | (a & (0x1FFF << 39));
for (uint i = 0;i < 8;i++) {
if(bool(s & (0x0f << i))) {
// straight
}
}
if(
bool(a & 0x1FFF) || bool(a & (0x1FFF << 13)) || bool(a & (0x1FFF << 26)) || bool(a & (0x1FFF << 39))) {
// flush
}else{
if(r3) {
// 3 card
if(r2 == 1) {
// full house
}
}else{
if(r2 == 1) {
// 1 pair
}else if(r2 == 2) {
// 2 pair
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment