-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathRobot.cpp
70 lines (57 loc) · 1.35 KB
/
Robot.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
#include "Robot.h"
#include "CallLordThread.h"
#include "PlayHandThread.h"
#include "Strategy.h"
Robot::Robot(QObject *parent)
{
m_type = Player::Robot;
}
void Robot::StartCallLord()
{
CallLordThread* thread = new CallLordThread(this);
thread->start();
}
void Robot::StartPlayHand()
{
PlayHandThread* thread = new PlayHandThread(this);
thread->start();
}
void Robot::ThinkForCallLord()
{
int weight = 0;
Strategy st(this, m_cards);
weight += st.GetRangeCards(Card_SJ, Card_BJ).Count() * 6;
weight += m_cards.PointCount(Card_2) * 3;
QVector<Cards> optSeq = st.PickOptimalSeqSingles();
weight += optSeq.size() * 5;
Cards left = m_cards;
left.Remove(optSeq);
Strategy stLeft(this, left);
QVector<Cards> bombs = stLeft.FindCardsByCount(4);
weight += bombs.size() * 5;
QVector<Cards> triples = stLeft.FindCardsByCount(3);
weight += triples.size() * 4;
QVector<Cards> pairs = stLeft.FindCardsByCount(2);
weight += pairs.size() * 1;
if (weight >= 22)
{
CallLord(3);
}
else if (weight < 22 && weight >= 18)
{
CallLord(2);
}
else if (weight > 18 && weight >= 10)
{
CallLord(1);
}
else
{
CallLord(0);
}
}
void Robot::ThinkForPlayHand()
{
Strategy strategy(this, m_cards);
PlayHand(strategy.MakeStrategy());
}