-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit_test.cpp
66 lines (57 loc) · 1.96 KB
/
unit_test.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
#include "common.h"
#include <string>
#include <cstdlib>
#include <cstdint>
#include "parser.hpp"
#include "searchalgorithm.hpp"
using std::string;
namespace unit_test {
void block_unit_test(const Board& board)
{
// b1
Block b1 {BlockColor::RED, BlockDirection::HORIZONTAL, 2, 0, 0};
b1.unit_test();
for(int i = 0; i < 36; i++)
if(b1.isBelongsToThisBlock(i)) {
cout << "the board index i: " << i
<< " is beloned to this block" << endl;
}
cout << b1 << endl;
// b2
Block b2 {BlockColor::BROWN, BlockDirection::VERTICAL, 3, 14, 1};
b2.unit_test();
for(int i = 0; i < 36; i++)
if(b2.isBelongsToThisBlock(i)) {
cout << "the board index i: " << i
<< " is beloned to this block" << endl;
}
cout << b2 << endl;
for(int i = 0; i < 36; ++i) {
cout << "blk idx of board index: " << i
<< " " << board.getBlockIndex(i) << endl;
}
cout << "--------------------" << endl;
for(int i = 0; i < board.getNumberOfBlocks(); ++i)
{
int twoIndices[2] {-1, -1};
board.getBlock(i).moveDistance(board.getBoard(), twoIndices);
}
}
// main function in unit_test
int main() {
Parser parser(string("input/e314"));
Board board(parser.getBoardFromFile());
cout << "Initial Board:" << endl;
cout << board;
// unit_test::block_unit_test(board);
SearchAlgorithm* algo = new BFSWithVistedStatesCheck(board, cout);
Board::setAlgorithm("BFS - Checking Visited states");
cout << Board::algorithm << endl;
algo->solveProblem();
SearchAlgorithm* algo2 = new AStar(board, cout);
Board::setAlgorithm("AStar - Checking Visited states");
cout << Board::algorithm << endl;
algo2->solveProblem();
return 0;
}
}