Page 1 of 1

Hold'em type

Posted: Fri Jun 08, 2007 11:09 am
by Zacariaz
Sounds weird?
probably is, but never the less i was thinking that something like this:

Code: Select all

struct T {
  struct Card {
    char val:4;
    char col:2;
  };
  Card Pocket[2];
  Card Flop[3];
  Card Turn;
  Card River;
};
Could probably be done alot smarter using template, typedef, or something simular. Only problem is that i never really have learned the how this stuff works.

Anywaym i was thinking if anyone could give me some pointers/hints or maybe even do it for me, i mean it shouldnt be alot of work.

Anyway ill be gratefull for any answer that doesnt aproach the subject that im a programmer of limited talents... :oops:

Posted: Fri Jun 08, 2007 12:13 pm
by Zacariaz
Of course the posibilitys are many:

Code: Select all

struct Card {
  unsigned col:2;
  unsigned val:4;
};
class T {
  std::bitset<6> Cards[7];
public:
  T(Card c0, Card c1) {
    Cards[0] = c0.col; Cards[0] |= c0.val << 2;
    Cards[1] = c1.col; Cards[1] |= c1.val << 2;
  }
  void Put_Flop(Card c2, Card c3, Card c4) {
    Cards[2] = c2.col; Cards[2] |= c2.val << 2;
    Cards[3] = c3.col; Cards[3] |= c3.val << 2;
    Cards[4] = c4.col; Cards[4] |= c4.val << 2;
  }
  void Put_Turn(Card c5) {Cards[5] = c5.col; Cards[5] |= c5.val << 2;}
  void Put_River(Card c6) {Cards[6] = c6.col; Cards[6] |= c6.val << 2;}
};