BlueBubble 1.0
A recommendation algorithm for movies based on a Netlfix database
Loading...
Searching...
No Matches
queen.cc
Go to the documentation of this file.
3#include "piece.h"
4#include "queen.h"
5#include <vector>
6#include <iostream>
7
11void queen::needed_space(coordinates dest, std::vector<coordinates> *to_calculate){
12 int diff_x = dest.get_x() - piece::coord.get_x();
13 int diff_y = dest.get_y() - piece::coord.get_y();
14 int coord_x = -1;
15 int coord_y = -1;
16 if(diff_x != 0 && diff_y != 0){
17 //When the queen moves like a bishop
18 for(int i = 1; i < abs(diff_x); i++){
19 if(diff_x > 0){
20 coord_x = piece::coord.get_x() + i;
21 }else{
22 coord_x = piece::coord.get_x() - i;
23 }
24 if(diff_y > 0){
25 coord_y = piece::coord.get_y() + i;
26 }else{
27 coord_y = piece::coord.get_y() - i;
28 }
29 to_calculate->push_back(coordinates(coord_x,coord_y));
30 }
31 }else{
32 //When the queen moves like a rook
33 if(dest.get_x() > piece::coord.get_x()){
34 //Moving right
35 for(int i = piece::coord.get_x() + 1; i < dest.get_x(); i++){
36 to_calculate->push_back(coordinates(i,piece::coord.get_y()));
37 }
38 }
39 if(dest.get_x() < piece::coord.get_x()){
40 //Moving left
41 for(int i = piece::coord.get_x() - 1; i > dest.get_x(); i--){
42 to_calculate->push_back(coordinates(i,piece::coord.get_y()));
43 }
44 }
45 if(dest.get_y() > piece::coord.get_y()){
46 //Moving right
47 for(int i = piece::coord.get_y() + 1; i < dest.get_y(); i++){
48 to_calculate->push_back(coordinates(piece::coord.get_x(),i));
49 }
50 }
51 if(dest.get_y() < piece::coord.get_y()){
52 //Moving left
53 for(int i = piece::coord.get_y() - 1; i > dest.get_y(); i--){
54 to_calculate->push_back(coordinates(piece::coord.get_x(),i));
55 }
56 }
57 }
58}
59
62 if(piece::white){
63 std::cout << "\u2655";
64 }else{
65 std::cout << "\u265B";
66 }
67}
68
71 if(piece::white){
72 std::cout << "wQ";
73 }else{
74 std::cout << "bQ";
75 }
76}
a class representing coordinates
Definition coordinates.h:5
int get_x()
a function to get the x-axis attribute
Definition coordinates.cc:6
int get_y()
a function to get the y-axis attribute
coordinates coord
Definition piece.h:14
bool white
Definition piece.h:13
void canonical_print_piece() override
print the piece to the standard output in canonical form
Definition queen.cc:70
void print_piece() override
print the piece to the standard output
Definition queen.cc:61
void needed_space(coordinates dest, std::vector< coordinates > *to_calculate) override
calculate a list of empty space coordinates needed for the move to be legal, assuming the move is pos...
Definition queen.cc:11