-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchess.cpp
More file actions
48 lines (40 loc) · 949 Bytes
/
chess.cpp
File metadata and controls
48 lines (40 loc) · 949 Bytes
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
#include "chess.hpp"
#include <iostream>
#include <memory>
using namespace chess;
void game::move(piece_p piece, pos to) {
board[to.x][to.y].p = piece;
}
void game::print() {
for (int j = 0; j < size; j++) {
std::cout << j+1 << ' ';
for (int i = 0; i < size; i++) {
if (board[i][j].is_occupied())
std::cout << board[i][j].p->repr();
else
std::cout << '.';
}
std::cout << '\n';
}
}
bool pawn::could_move(pos from, pos to) {
return false;
}
char pawn::repr() {
return 'p';
}
void game::set_start_position() {
for (int i = 0; i < size; i++) {
piece_p p(new pawn(color::white));
board[i][1].p = p;
pieces.push_back(p);
piece_p pb(new pawn(color::black));
board[i][6].p = pb;
pieces.push_back(pb);
}
}
int main () {
game game;
game.set_start_position();
game.print();
}