-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cc
executable file
·108 lines (93 loc) · 3.98 KB
/
test.cc
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
#include "ChessBoard/ChessBoard.h"
#include "CommandInterpreter/CommandInterpreter.h"
#include "ObserverPattern/GraphicsObserver.h"
#include "ObserverPattern/TextObserver.h"
// int main() {
// std::shared_ptr<ChessBoard> board = std::make_shared<ChessBoard>();
// TextObserver text_observer(board, std::cout);
// GraphicsObserver graphics_observer(board);
// board->defaultSetup();
// board->render();
// // Try to get attacked squares of a pawn
// Position pawn_pos{6, 1};
// if (board->getSquare(pawn_pos).getPiece() == nullptr) {
// std::cerr << "No piece found at " << pawn_pos.r << " " << pawn_pos.c
// << std::endl;
// return 1;
// }
// if (board->getSquare(pawn_pos).getPiece()->getPieceChar() != 'P') {
// std::cerr << "Piece at " << pawn_pos.r << " " << pawn_pos.c
// << " is not a pawn" << std::endl;
// return 1;
// }
// std::unordered_set<Position> pawn_attacked_squares =
// board->getSquare(pawn_pos).getPiece()->getAttackedSquares();
// for (const Position& pos : pawn_attacked_squares) {
// std::cout << pos.r << " " << pos.c << " attacked by pawn!" << std::endl;
// }
// // Test rook attacked squares
// Position rook_pos{7, 7};
// if (board->getSquare(rook_pos).getPiece() == nullptr) {
// std::cerr << "No piece found at " << rook_pos.r << " " << rook_pos.c
// << std::endl;
// return 1;
// }
// if (board->getSquare(rook_pos).getPiece()->getPieceChar() != 'R') {
// std::cerr << "Piece at " << rook_pos.r << " " << rook_pos.c
// << " is not a rook" << std::endl;
// return 1;
// }
// std::unordered_set<Position> rook_attacked_squares =
// board->getSquare(rook_pos).getPiece()->getAttackedSquares();
// for (const Position& pos : rook_attacked_squares) {
// std::cout << pos.r << " " << pos.c << " attacked by rook!" << std::endl;
// }
// // Test queen attacked squares
// std::cout << "Testing queen attacked squares" << std::endl;
// Position queen_pos{7, 3};
// if (board->getSquare(queen_pos).getPiece() == nullptr) {
// std::cerr << "No piece found at " << queen_pos.r << " " << queen_pos.c
// << std::endl;
// return 1;
// }
// if (board->getSquare(queen_pos).getPiece()->getPieceChar() != 'Q') {
// std::cerr << "Piece at " << queen_pos.r << " " << queen_pos.c
// << " is not a queen" << std::endl;
// return 1;
// }
// std::unordered_set<Position> queen_attacked_squares =
// board->getSquare(queen_pos).getPiece()->getAttackedSquares();
// for (const Position& pos : queen_attacked_squares) {
// std::cout << pos.r << " " << pos.c << " attacked by queen!" << std::endl;
// }
// // Test knight attacked squares
// std::cout << "Testing knight attacked squares" << std::endl;
// Position knight_pos{7, 1};
// if (board->getSquare(knight_pos).getPiece() == nullptr) {
// std::cerr << "No piece found at " << knight_pos.r << " " << knight_pos.c
// << std::endl;
// return 1;
// }
// if (board->getSquare(knight_pos).getPiece()->getPieceChar() != 'N') {
// std::cerr << "Piece at " << knight_pos.r << " " << knight_pos.c
// << " is not a knight" << std::endl;
// return 1;
// }
// std::unordered_set<Position> knight_attacked_squares =
// board->getSquare(knight_pos).getPiece()->getAttackedSquares();
// for (const Position& pos : knight_attacked_squares) {
// std::cout << pos.r << " " << pos.c << " attacked by knight!" << std::endl;
// }
// // Don't exit program
// while (true) {
// }
// return 0;
// }
int main() {
std::cout << "Begin Game" << std::endl;
while (CommandInterpreter::processGameInput()) {
}
// Return final scores
Manager::getLeaderBoard().printScores(true);
return 0;
}