forked from nathansttt/hearts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiiMonteCarlo.h
executable file
·63 lines (56 loc) · 1.79 KB
/
iiMonteCarlo.h
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
#include "Algorithm.h"
#include "algorithmStates.h"
#include <vector>
#ifdef __MAC__
#include <CoreServices/CoreServices.h>
//#include <Multiprocessing.h>
#endif
#ifndef iiMonteCarlo_h
#define iiMonteCarlo_h
class threadModel {
public:
Algorithm *alg;
GameState *gs;
#ifdef __MAC__
MPQueueID returnQ;
#endif
};
enum decisionRule {
kMaxWeighted,
kMaxAverage,
kMaxAvgVar,
kMaxMinScore
};
class iiMonteCarlo : public Algorithm {
public:
iiMonteCarlo(Algorithm *a, int numModels, int numChoices = -1);
iiMonteCarlo(Player *_player, int numModels);
~iiMonteCarlo();
Algorithm *clone() const { return new iiMonteCarlo(*this); }
returnValue *Play(GameState *g, Player *p);
returnValue *Analyze(GameState *g, Player *p);
returnValue *DispatchSearch(unsigned int depth, int cp, GameState *g);
Algorithm *getAlgorithm() { return algorithm; }
int getNumModels() { return numModels; }
void setNumModels(int val) { numModels = val; }
const char *getName();
void setDecisionRule(decisionRule r) { dr = r; }
private:
const char *getDecisionName();
Move *Combine(GameState *g, std::vector<returnValue *> &v, int who, std::vector<double> &probs);
returnValue *CombinedAnalyze(GameState *g, std::vector<returnValue *> &v, int who, std::vector<double> &probs);
void doModels(GameState *g, Player *p, std::vector<returnValue *> &v, std::vector<double> &probs);
void doThreadedModels(GameState *g, Player *p, std::vector<returnValue *> &v, std::vector<double> &probs);
void GetGameStates(GameState *g, Player *p, std::vector<GameState *> &states, std::vector<double> &probs);
void NormalizeProbs(std::vector<double> &pr);
int numModels, numChoices;
Algorithm *algorithm;
Player *player;
decisionRule dr;
};
#ifdef __MAC__
OSStatus doThreadedModel(void *data);
#else
void *doThreadedModel(void *data);
#endif
#endif