-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_dds.cpp
More file actions
82 lines (68 loc) · 1.75 KB
/
test_dds.cpp
File metadata and controls
82 lines (68 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <string.h>
#include <iostream>
#include "include/dll.h"
#include "gtest/gtest.h"
static void PrintDDSDebugInfo(const struct futureTricks &fut) {
printf("nodes=%d cards=%d\n", fut.nodes, fut.cards);
for (int i = 0; i < fut.cards; ++i) {
printf("i=%d suit=%d rank=%d equals=%d score=%d\n", i, fut.suit[i],
fut.rank[i], fut.equals[i], fut.score[i]);
}
}
enum class Suit {
SPADES = 0,
HEARTS = 1,
DIAMONDS = 2,
CLUBS = 3,
NOTRUMP = 4
};
enum class Compass { NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3 };
static int rank(char c);
TEST(TestDDS, Solve) {
const int target = -1, solutions = 3, mode = 1;
SetMaxThreads(0);
struct dealPBN dds_deal;
struct futureTricks fut;
memset(&dds_deal, 0, sizeof(deal));
memset(&fut, 0, sizeof(futureTricks));
// DA removed from S holding
strcpy(dds_deal.remainCards, "N:KJ..5. QT...T 5...9 97.9..");
dds_deal.currentTrickSuit[0] = static_cast<int>(Suit::DIAMONDS);
dds_deal.currentTrickRank[0] = 14; // rank('A');
dds_deal.first = static_cast<int>(Compass::SOUTH);
dds_deal.trump = static_cast<int>(Suit::NOTRUMP);
int rc = SolveBoardPBN(dds_deal, target, solutions, mode, &fut,
/* threadIndex */ 0);
char line[80];
ErrorMessage(rc, line);
EXPECT_EQ(RETURN_NO_FAULT, rc) << line;
if (rc == RETURN_NO_FAULT) {
PrintDDSDebugInfo(fut);
}
EXPECT_EQ(0, fut.score[0]);
EXPECT_EQ(0, fut.score[1]);
}
static int rank(char c) {
int r = c - '0';
if (r >= 2 && r <= 9) {
return r;
}
switch (c) {
case 't':
case 'T':
return 10;
case 'j':
case 'J':
return 11;
case 'q':
case 'Q':
return 12;
case 'k':
case 'K':
return 13;
case 'A':
case 'a':
return 14;
}
return 0;
}