-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmain.cpp
125 lines (106 loc) · 2.82 KB
/
main.cpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <windows.h>
#include <vector>
#include <algorithm>
#include "HuPaiMJ2.h"
#include "HuPaiMJ3.h"
#include "HuPaiMJ4.h"
using namespace std;
void print_cards(bool bSuc1, bool bSuc2, BYTE* cards)
{
printf("%d%d ", bSuc1, bSuc2);
for (int i = 0; i < 9; ++i)
{
printf("%d,", cards[i]);
}
printf(" ");
for (int i = 9; i < 18; ++i)
{
printf("%d,", cards[i]);
}
printf(" ");
for (int i = 18; i < 27; ++i)
{
printf("%d,", cards[i]);
}
printf(" ");
for (int i = 27; i < 34; ++i)
{
printf("%d,", cards[i]);
}
printf("\n");
}
#define GUI_NUM 3
#define MAX_COUNT (100 * 10000)
static BYTE g_HuCardAll[136];
CHuPaiMJ stTssss;
ArrayMJ::CHuPaiArrayMJ stArray;
FinalMJ::CHuPaiArrayMJ stFinal;
void test_repeat()
{
BYTE cards[] = {
1,1,2,0,0,0,0,0,0, 0,0,0,0,2,0,0,0,0, 0,0,4,0,1,0,0,0,0, 0,0,0,0,0,0,3
};
int hu = stFinal.CheckCanHu(cards, 33);
cout << "hu:" << hu << endl;
}
BYTE source[MAX_COUNT * 9 * 34];
void main()
{
stFinal.TrainAll();
//test_repeat();
stArray.TrainAll();
stTssss.TrainAll();
for (int i = 0; i < 34; i++)
{
g_HuCardAll[i * 4] = i;
g_HuCardAll[i * 4 + 1] = i;
g_HuCardAll[i * 4 + 2] = i;
g_HuCardAll[i * 4 + 3] = i;
}
int gui_index = 33;
int total = 0;
srand(11);
for (int n = 0; n < MAX_COUNT; ++n)
{
random_shuffle(g_HuCardAll, g_HuCardAll + 130); // 这个函数对计算有影响
for (int i = 0; i < 9; ++i) // 136/14 -> 9
{
BYTE* cards = &source[total++ * 34];
memset(cards, 0, 34);
for (int j = i * 14; j < i * 14 + 14 - GUI_NUM; j++)
++cards[g_HuCardAll[j]];
cards[gui_index] = GUI_NUM;
}
}
printf("gui_index=%d GUI_NUM=%d\n", gui_index, GUI_NUM);
// // 判断是否结果一致
for (int n = 0; n < total; ++n)
{
bool bSuc1 = stTssss.CheckCanHu(source + n * 34, gui_index);
bool bSuc2 = stFinal.CheckCanHu(source + n * 34, gui_index);
if (bSuc1 != bSuc2)
print_cards(bSuc1, bSuc2, source + n * 34);
}
// rjc查表法
int hu = 0;
DWORD dwTimeBegin = GetTickCount();
for (int n = 0; n < total; ++n)
hu += stTssss.CheckCanHu(source + n * 34, gui_index);
cout << "rjc查表法总数:" << total / 10000 << "万次, time:" << GetTickCount() - dwTimeBegin << "ms" << endl;
cout << "Hu: " << hu << endl;
// memcpy(sourceTemp, source, sizeof(sourceTemp));
hu = 0;
dwTimeBegin = GetTickCount();
for (int n = 0; n < total; ++n)
hu += stArray.CheckCanHu(source + n * 34, gui_index);
cout << "rjc数组法总数:" << total / 10000 << "万次, time:" << GetTickCount() - dwTimeBegin << "ms" << endl;
cout << "Hu: " << hu << endl;
hu = 0;
dwTimeBegin = GetTickCount();
for (int n = 0; n < total; ++n)
hu += stFinal.CheckCanHu(source + n * 34, gui_index);
cout << "rjc混合法总数:" << total / 10000 << "万次, time:" << GetTickCount() - dwTimeBegin << "ms" << endl;
cout << "Hu: " << hu << endl;
cin >> hu;
}