int wrap_StdDeck_CardMask_IS_EMPTY(StdDeck_CardMask mask) { return StdDeck_CardMask_IS_EMPTY(mask); }
Esempio n. 2
0
void
enumResultPrint(enum_result_t *result, StdDeck_CardMask pockets[],
                StdDeck_CardMask board) {
  int i;
  enum_gameparams_t *gp;
  int width;

  gp = enumGameParams(result->game);
  if (gp == NULL) {
    printf("enumResultPrint: invalid game type\n");
    return;
  }
  width = gp->maxpocket * 3 - 1;
  printf("%s: %d %s %s%s", gp->name, result->nsamples,
         (result->sampleType == ENUM_SAMPLE) ? "sampled" : "enumerated",
         (gp->maxboard > 0) ? "board" : "outcome",
         (result->nsamples == 1 ? "" : "s"));
  if (!StdDeck_CardMask_IS_EMPTY(board))
    printf(" containing %s", DmaskString(StdDeck, board));
  printf("\n");

  if (gp->haslopot && gp->hashipot) {
    printf("%*s %7s   %7s %7s %7s   %7s %7s %7s   %5s\n",
           -width, "cards", "scoop",
           "HIwin", "HIlos", "HItie",
           "LOwin", "LOlos", "LOtie",
           "EV");
    for (i=0; i<(int)(result->nplayers); i++) {
      printf("%*s %7d   %7d %7d %7d   %7d %7d %7d   %5.3f\n",
             -width, DmaskString(StdDeck, pockets[i]), result->nscoop[i],
             result->nwinhi[i], result->nlosehi[i], result->ntiehi[i],
             result->nwinlo[i], result->nloselo[i], result->ntielo[i],
             result->ev[i] / result->nsamples);
    }
#if 0
    {
    int j;
    /* experimental output format to show pot splitting */
    printf("\n%*s", -width, "cards");
    for (j=0; j<=result->nplayers; j++)
      printf(" %6s%d", "HI", j);
    for (j=0; j<=result->nplayers; j++)
      printf(" %6s%d", "LO", j);
    printf("\n");
    for (i=0; i<result->nplayers; i++) {
      printf("%*s", -width, DmaskString(StdDeck, pockets[i]));
      for (j=0; j<=result->nplayers; j++)
        printf(" %7d", result->nsharehi[i][j]);
      for (j=0; j<=result->nplayers; j++)
        printf(" %7d", result->nsharelo[i][j]);
      printf("\n");
    }
    }
#endif
    
  } else {
    printf("%*s %7s %6s   %7s %6s   %7s %6s     %5s\n",
           -width, "cards", "win", "%win", "lose", "%lose", "tie", "%tie", "EV");
    if (gp->haslopot) {
      for (i=0; i<(int)(result->nplayers); i++) {
        printf("%*s %7d %6.2f   %7d %6.2f   %7d %6.2f     %5.3f\n",
               -width, DmaskString(StdDeck, pockets[i]),
               result->nwinlo[i], 100.0 * result->nwinlo[i] / result->nsamples,
               result->nloselo[i], 100.0 * result->nloselo[i] / result->nsamples,
               result->ntielo[i], 100.0 * result->ntielo[i] / result->nsamples,
               result->ev[i] / result->nsamples);
      }
    } else if (gp->hashipot) {
      for (i=0; i<(int)(result->nplayers); i++) {
        printf("%*s %7d %6.2f   %7d %6.2f   %7d %6.2f     %5.3f\n",
               -width, DmaskString(StdDeck, pockets[i]),
               result->nwinhi[i], 100.0 * result->nwinhi[i] / result->nsamples,
               result->nlosehi[i], 100.0 * result->nlosehi[i] / result->nsamples,
               result->ntiehi[i], 100.0 * result->ntiehi[i] / result->nsamples,
               result->ev[i] / result->nsamples);
      }
    }
  }

  if (result->ordering != NULL)
    enumResultPrintOrdering(result, 0);
}
Esempio n. 3
0
static PyObject*
CardMask2SortedPyList(CardMask hand, int low)
{
  int i;
  HandVal handval;
  PyObject* result = PyList_New(0);

  if(StdDeck_CardMask_IS_EMPTY(hand)) {
    PyObject* pyvalue = Py_BuildValue("s", "Nothing");
    PyList_Append(result, pyvalue);
    Py_DECREF(pyvalue);
    return result;
  }

  if(low) {
    handval = Hand_EVAL_LOW8(hand, 5);
  } else {
    handval = Hand_EVAL_N(hand, 5);
  }

  int htype = HandVal_HANDTYPE(handval);
  {
    PyObject* pyvalue = Py_BuildValue("s", StdRules_handTypeNames[htype]);
    PyList_Append(result, pyvalue);
    Py_DECREF(pyvalue);
  }

  if(!low || htype != LowHandVal_NOTHING) {
    if (StdRules_nSigCards[htype] >= 1) {
      int rank = HandVal_TOP_CARD(handval);
      if(low) rank = LOWRANK2RANK(rank);

      if(htype == HandType_STRAIGHT || htype == HandType_STFLUSH) {
	for(i = rank; rank - i < 5; i--) {
	  int rank_modulo = i < 0 ? StdDeck_Rank_ACE : i;
	  PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank_modulo));
	  PyList_Append(result, pyvalue);
	  Py_DECREF(pyvalue);
	}
      } else {
	int count;
	switch(htype) {
	case HandType_ONEPAIR:
	case HandType_TWOPAIR:
	  count = 2;
	  break;
	case HandType_TRIPS:
	case HandType_FULLHOUSE:
	  count = 3;
	  break;
	case HandType_QUADS:
	  count = 4;
	  break;
	default:
	  count = 1;
	  break;
	}
	for(i = 0; i < count; i++) {
	  PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank));
	  PyList_Append(result, pyvalue);
	  Py_DECREF(pyvalue);
	}
      }
    }
    if (StdRules_nSigCards[htype] >= 2) {
      int rank = HandVal_SECOND_CARD(handval);
      int count = 1;
      if(low) rank = LOWRANK2RANK(rank);
      if(htype == HandType_TWOPAIR ||
	 htype == HandType_FULLHOUSE)
	count = 2;

      for(i = 0; i < count; i++) {
	PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank));
	PyList_Append(result, pyvalue);
	Py_DECREF(pyvalue);
      }
    }

    if (StdRules_nSigCards[htype] >= 3) {
      int rank = HandVal_THIRD_CARD(handval);
      if(low) rank = LOWRANK2RANK(rank);
      PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank));
      PyList_Append(result, pyvalue);
      Py_DECREF(pyvalue);
    }

    if (StdRules_nSigCards[htype] >= 4) {
      int rank = HandVal_FOURTH_CARD(handval);
      if(low) rank = LOWRANK2RANK(rank);
      PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank));
      PyList_Append(result, pyvalue);
      Py_DECREF(pyvalue);
    }

    if (StdRules_nSigCards[htype] >= 5) {
      int rank = HandVal_FIFTH_CARD(handval);
      if(low) rank = LOWRANK2RANK(rank);
      PyObject* pyvalue = Py_BuildValue("i", findanddelete(&hand, rank));
      PyList_Append(result, pyvalue);
      Py_DECREF(pyvalue);
    }

  }

  /*
   * Append remaining cards, highest first
   */
  for(i = Deck_N_CARDS - 1; i >= 0; i--) {
    if (StdDeck_CardMask_CARD_IS_SET(hand, i)) {
      PyObject* pyvalue = Py_BuildValue("i", i);
      PyList_Append(result, pyvalue);
      Py_DECREF(pyvalue);
    }
  }

  return result;
}