-
Notifications
You must be signed in to change notification settings - Fork 6
/
source.cpp
105 lines (86 loc) · 2.95 KB
/
source.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
#pragma once
#include<iostream>
#include<vector>
#include<map>
#include"MoveGenerator/MoveGenerator.h"
#include"Evaluators/MidgameEvaluator.h"
#include"Models/Board.h"
#include"Models/Play.h"
#include"Models/Rack.h"
#include"Models/Tile.h"
#include"Models/Bag.h"
#include"Models/Agent.h"
#include"Models/HumanMode.h"
#include"GADDAG/GADDAG.h"
#include "Evaluators/MidgameEvaluator.h"
#include "Integration/GameManager.h"
#include "Integration/Structs.cpp"
#include "Evaluators/PreendgameEvaluator.h"
#include "Strategy/SuperLeaveLoader.h"
#include <time.h>
#include <chrono>
#include<thread>
using namespace std;
string GADDAG_PATH = "assets/Dict.txt";
string BAG_PATH = "assets/letters.txt";
Board board;
//
Rack RACK;
//GADDAG DAG(GADDAG_PATH);
int main(){
Bag bag(BAG_PATH);
MoveGenerator movGen(board);
map<string, double>* syn2 = new map<string, double>();
map<char, double>* worth = new map<char, double>();
SuperLeaveLoader loader(syn2, worth, "assets/syn2", "assets/worths");
cout << "Loaded the rack leave map with count " << syn2->size() << endl;
GameManager manager;
manager.InitGame(&movGen, syn2, worth);
std::thread thread1(&Comm::ThinkingThread);
std::thread thread2(&Comm::ConnectServer);
bool ended=false;
while(!ended){
manager.PlayAI(ended, &board, &bag);
}
// GameManager gameManager;
// gameManager.InitGame();
// string Mode = gameManager.GetMode();
// cout << "Mode = " << Mode << endl;
// MoveGenerator movGen(board);
// map<string, double>* syn2 = new map<string, double>();
// map<char, double>* worth = new map<char, double>();
// SuperLeaveLoader loader(syn2, worth, "assets/syn2", "assets/worths");
// cout << "Loaded the rack leave map with count " << syn2->size() << endl;
// if (Mode == "AIMODE"){ //AI Mode
// vector<Move> moves;
// Rack rack;
// Agent AI_Agent(&board, &bag, &rack);
// Move pass = AI_Agent.GetPassMove();
// Move chosenMove;
// bool GameOver= false; //should be over when all 100 tiles are played or when we pass and opponent pass
// while(!GameOver){
// bool MyTurn= true;
// if (MyTurn){
// auto start = chrono::high_resolution_clock::now();
// moves = movGen.Generate(&rack, board, board.GetCount()==0);
// auto end = chrono::high_resolution_clock::now();
// int numTilesByOpponent =3;
// int BagSize = (int)bag.GetRemainigLetters().size();
// if (BagSize > 9){//MidGame
// chosenMove = AI_Agent.MidGame(moves, syn2, worth,&movGen, numTilesByOpponent); //should return best move
// }
// else if (BagSize > 0 && BagSize <=9){
// chosenMove = AI_Agent.PreEndGame(syn2,worth,&movGen,moves, numTilesByOpponent); //should return best move
// }
// else if (BagSize == 0){
// //AI_Agent.EndGame(moves); //should return best move
// }
// moves.clear();
// }
// }
// }
// else { //Human Mode
// gameManager.PlayHuman(&board, &bag, &movGen, syn2, worth);
// }
// //send to GUI game is over
}