Skip to content

Commit

Permalink
fix statistical modelling
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed Sep 22, 2010
1 parent 5c2137c commit 34bdafb
Show file tree
Hide file tree
Showing 15 changed files with 23,620 additions and 34 deletions.
68 changes: 68 additions & 0 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,71 @@ QString Card::toString() const

return r;
}

Card Card::fromString(const QString &string)
{
Suit suit;
Value value;
switch(string[0].toAscii()) {
case 'S':
suit = Card::Spade;
break;
case 'H':
suit = Card::Heart;
break;
case 'C':
suit = Card::Club;
break;
case 'D':
suit = Card::Diamond;
break;
default:
suit = (Card::Suit)-1;
}

switch(string[1].toAscii()) {
case '2':
value = Card::Two;
break;
case '3':
value = Card::Three;
break;
case '4':
value = Card::Four;
break;
case '5':
value = Card::Five;
break;
case '6':
value = Card::Six;
break;
case '7':
value = Card::Seven;
break;
case '8':
value = Card::Eight;
break;
case '9':
value = Card::Nine;
break;
case '0':
value = Card::Ten;
break;
case 'J':
value = Card::Jack;
break;
case 'Q':
value = Card::Queen;
break;
case 'K':
value = Card::King;
break;
case 'A':
value = Card::Ace;
break;
default:
value = (Card::Value)-1;
}

return Card(value, suit);
}
2 changes: 2 additions & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Card

QString toString() const;

static Card fromString(const QString &string);

private:
Value m_value;
Suit m_suit;
Expand Down
8 changes: 0 additions & 8 deletions context.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions context.h

This file was deleted.

25 changes: 25 additions & 0 deletions deck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "card.h"
#include <QDebug>
#include <QStringList>

Deck::Deck() : QList<Card>()
{
Expand Down Expand Up @@ -375,3 +376,27 @@ void Deck::removeCards(const Deck &hand){
}
}
}

QString Deck::toString() const
{
QString ret;

for (int i=0; i<size(); i++) {
if (i)
ret += ',';
ret += at(i).toString();
}

return ret;
}

Deck Deck::fromString(QString string)
{
Deck ret;
QStringList cards = string.split(',');
foreach(const QString &card, cards) {
ret.append(Card::fromString(card));
}

return ret;
}
3 changes: 3 additions & 0 deletions deck.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Deck : public QList<Card>

void removeCards(const Deck &cards);

QString toString() const;
static Deck fromString(QString string);


private:

Expand Down
4 changes: 2 additions & 2 deletions holdme.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ SOURCES += main.cpp \
test.cpp \
preflopplayer.cpp \
statisticalmodel.cpp \
context.cpp
statisticalplayer.cpp
HEADERS += player.h \
table.h \
card.h \
deck.h \
preflop.h \
preflopplayer.h \
statisticalmodel.h \
context.h
statisticalplayer.h
Loading

0 comments on commit 34bdafb

Please sign in to comment.