void partial_evaluate(unsigned int cardcnt, char* cards, partial_evaluation* pe) { unsigned int i, r, c; assert_local(cardcnt); // there must be more than one card pe->evaluated = cardcnt; for (i=0; i < 4; i++) { pe->flushnodes[i] = 0; pe->colors[i] = 0; } for (i=0; i < cardcnt; i++) { r = cards[i] >> 2; c = cards[i] & 3; // follow the dag for non-flush nodes if (!i) { pe->noflushnode = &(dag[r]); } else { pe->noflushnode = pe->noflushnode->succs[r]; } // follow the dag for flush color candidates nodes pe->colors[c]++; if (pe->flushnodes[c] == 0) { pe->flushnodes[c] = &(dag[r]); } else { pe->flushnodes[c] = pe->flushnodes[c]->succs[r]; } } }
handeval_eq_class* resume_evaluation(char* cards, const partial_evaluation* pe) { unsigned int i, r, c; handeval_dag_node *n = pe->noflushnode; unsigned int remain = 7 - pe->evaluated; int cl; char col[4] = {pe->colors[0], pe->colors[1], pe->colors[2], pe->colors[3]}; for (i=0; i < remain; i++) { r = cards[i] >> 2; c = cards[i] & 3; n = n->succs[r]; // follow the non-flush dag col[c]++; } // check for flushes int fc = -1; for (i=0; i < 4; i++) { if (col[i] >= 5) { fc = i; break; } } assert_local(n->equiv_class_normal > 0); if (fc >= 0) { n = pe->flushnodes[fc]; for (i=0; i < remain; i++) { c = cards[i] & 3; if ((int) c == fc) { r = cards[i] >> 2; if (n) { n = n->succs[r]; } else { n = &(dag[r]); } } }
void view_assert_local(V<T, B> v, index_type i) { assert_local(v.block(), i); }