Permalink
Browse files

initial check-in of evaluation libraries

  • Loading branch information...
andrewprock committed May 3, 2013
1 parent 52eb58e commit b8d1a9236b334981d8c841edb41350d93f4f71d3
Showing with 33,295 additions and 0 deletions.
  1. +35 −0 LICENSE.txt
  2. +10 −0 libs/CMakeLists.txt
  3. +49 −0 libs/pokerstove/peval/BadugiHandEvaluator.h
  4. +14 −0 libs/pokerstove/peval/CMakeLists.txt
  5. +72 −0 libs/pokerstove/peval/Card.cpp
  6. +83 −0 libs/pokerstove/peval/Card.h
  7. +1,419 −0 libs/pokerstove/peval/CardSet.cpp
  8. +202 −0 libs/pokerstove/peval/CardSet.h
  9. +52 −0 libs/pokerstove/peval/DeuceToSevenHandEvaluator.h
  10. +52 −0 libs/pokerstove/peval/DrawHighHandEvaluator.h
  11. +23 −0 libs/pokerstove/peval/Holdem.h
  12. +49 −0 libs/pokerstove/peval/HoldemHandEvaluator.h
  13. +216 −0 libs/pokerstove/peval/OmahaEightHandEvaluator.h
  14. +144 −0 libs/pokerstove/peval/OmahaHighHandEvaluator.h
  15. +523 −0 libs/pokerstove/peval/PokerEvaluation.cpp
  16. +192 −0 libs/pokerstove/peval/PokerEvaluation.h
  17. +27,798 −0 libs/pokerstove/peval/PokerEvaluationTables.h
  18. +284 −0 libs/pokerstove/peval/PokerHand.cpp
  19. +150 −0 libs/pokerstove/peval/PokerHand.h
  20. +128 −0 libs/pokerstove/peval/PokerHandEvaluation.h
  21. +100 −0 libs/pokerstove/peval/PokerHandEvaluator.cpp
  22. +179 −0 libs/pokerstove/peval/PokerHandEvaluator.h
  23. +116 −0 libs/pokerstove/peval/PokerHandEvaluator_Alloc.cpp
  24. +78 −0 libs/pokerstove/peval/Rank.cpp
  25. +133 −0 libs/pokerstove/peval/Rank.h
  26. +40 −0 libs/pokerstove/peval/RazzHandEvaluator.h
  27. +30 −0 libs/pokerstove/peval/StudEightHandEvaluator.h
  28. +41 −0 libs/pokerstove/peval/StudHandEvaluator.h
  29. +271 −0 libs/pokerstove/peval/Suit.cpp
  30. +132 −0 libs/pokerstove/peval/Suit.h
  31. +193 −0 libs/pokerstove/peval/UniversalHandEvaluator.h
  32. +323 −0 libs/pokerstove/util/combinations.h
  33. +89 −0 libs/pokerstove/util/lastbit.h
  34. +75 −0 libs/pokerstove/util/utypes.h
View
@@ -0,0 +1,35 @@
Copyright (c) 2012, Andrew C. Prock.
All rights reserved.
Redistribution and use in source and binary forms, with o without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain
the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must
reproduce the above copyright notice, this
list of conditions and the following
disclaimer in the documentation and/or
other materials provided with the
distribution.
* Neither the name of the Andrew C. Prock nor
the names of its contributors may be used
to endorse or promote products derived from
this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.4)
project(pokerstove)
include_directories(".")
#add_definitions ("-ansi -pedantic -Wall -Wextra")
add_definitions ("-ansi -Wall")
add_subdirectory (pokerstove/peval)
@@ -0,0 +1,49 @@
/**
* Copyright (c) 2012 Andrew Prock. All rights reserved.
* $Id: BadugiHandEvaluator.h 2649 2012-06-30 04:53:24Z prock $
*/
#ifndef PEVAL_BADUGIHANDEVALUATOR_H_
#define PEVAL_BADUGIHANDEVALUATOR_H_
#include "PokerHandEvaluator.h"
namespace pokerstove
{
/**
* A specialized hand evaluator for hold'em. Not as slow.
*/
class BadugiHandEvaluator : public PokerHandEvaluator
{
public:
BadugiHandEvaluator ()
: PokerHandEvaluator ()
, _numDraws(0)
{}
virtual PokerHandEvaluation evaluateHand (const CardSet & hand, const CardSet&) const
{
return PokerHandEvaluation(hand.evaluateBadugi ());
}
virtual PokerEvaluation evaluateRanks (const CardSet & hand, const CardSet& board=CardSet(0)) const
{
throw std::runtime_error ("BadugiHandEvaluator::evaluateRanks, not implemented");
}
virtual PokerEvaluation evaluateSuits (const CardSet & hand, const CardSet& board=CardSet(0)) const
{
throw std::runtime_error ("BadugiHandEvaluator::evaluateSuits, not implemented");
}
virtual size_t handSize () const { return 4; }
virtual size_t boardSize () const { return 0; }
virtual size_t evaluationSize () const { return 1; }
virtual size_t numDraws () const { return _numDraws; }
virtual void setNumDraws (size_t sz) { _numDraws = sz; }
private:
size_t _numDraws;
};
}
#endif // PEVAL_BADUGIHANDEVALUATOR_H_
@@ -0,0 +1,14 @@
# peval library
set(sources
Card.cpp
CardSet.cpp
PokerEvaluation.cpp
PokerHand.cpp
PokerHandEvaluator.cpp
PokerHandEvaluator_Alloc.cpp
Rank.cpp
Suit.cpp
)
add_library(peval ${sources})
@@ -0,0 +1,72 @@
/**
* Copyright (c) 2012 Andrew Prock. All rights reserved.
* $Id: Card.cpp 2649 2012-06-30 04:53:24Z prock $
*/
#include <iostream>
#include "Rank.h"
#include "Suit.h"
#include "Card.h"
using pokerstove::Suit;
using pokerstove::Rank;
using pokerstove::Card;
Card::Card ()
: _card(0)
{}
Card::Card (const std::string& str)
: _card(0)
{
fromString (str);
}
Card::Card (const Rank& r, const Suit& s)
: _card(encode(r,s))
{}
Card::Card (uint8_t cindex)
: _card(cindex)
{}
Rank Card::rank () const
{
return Rank (_card%Rank::NUM_RANK);
}
Suit Card::suit () const
{
return Suit (_card/Rank::NUM_RANK);
}
std::string Card::str () const
{
return rank().str()+suit().str();
}
bool Card::fromString (const std::string & str)
{
if (Rank::isRankChar (str[0]) && Suit::isSuitChar (str[1]))
{
_card = encode (Rank(str),Suit(str.substr(1)));
return true;
}
return false;
}
int Card::code () const
{
return _card;
}
uint8_t Card::encode (Rank r, Suit s)
{
return r.code () + s.code () * Rank::NUM_RANK;
}
bool Card::operator< (const Card& r) const
{
if ((_card%Rank::NUM_RANK) == (r._card%Rank::NUM_RANK))
return _card/Rank::NUM_RANK < r._card/Rank::NUM_RANK;
return _card%Rank::NUM_RANK < r._card%Rank::NUM_RANK;
}
@@ -0,0 +1,83 @@
/**
* Copyright (c) 2012 Andrew Prock. All rights reserved.
* $Id: Card.h 2649 2012-06-30 04:53:24Z prock $
*/
#ifndef PEVAL_CARD_H_
#define PEVAL_CARD_H_
#include <string>
#include <boost/cstdint.hpp>
namespace pokerstove
{
// forward declarations,
class Suit;
class Rank;
/**
* This card class is designed to make the manipulation and
* abstraction of cards as friendly as possible.
*
* The Card class is an external representation, and there is no
* guarantee that Card objects are used internally in the library.
* The goal of the representation issues which may cause portability
* and translation problems. They also store some partial evals.
*
* transforming suits to strings can be controlled so that the string
* generated is suitable for the display format. This does *not*
* apply to string parsing. Strings may only be parsed from the set
* of characters: {cdhs}
*/
class Card
{
public:
Card ();
explicit Card (const std::string& str);
explicit Card (const Rank& r, const Suit& s);
/**
* use of this constructor is discouraged, the safest use is to
* (re)construct cards from saved codes.
*/
explicit Card (uint8_t cindex);
Rank rank () const;
Suit suit () const;
/**
* use of this method is discouraged
*/
int code () const;
/**
* string representation of card,
* @see Suit::display
* @see Suit::setSuitStringType()
*/
std::string str () const;
/**
* provide checked parsing of the first two chars of the input string.
*/
bool fromString (const std::string & s);
/**
* required for storage in STL containers
*/
bool operator== (const Card& r) const { return _card == r._card; }
/**
* required for storage in STL containers
*/
bool operator< (const Card& r) const;
private:
static uint8_t encode (Rank r, Suit s);
friend class CardSet;
uint8_t _card;
};
}
#endif // PEVAL_CARD_H_
Oops, something went wrong.

0 comments on commit b8d1a92

Please sign in to comment.