BlueBubble 1.0
A recommendation algorithm for movies based on a Netlfix database
Loading...
Searching...
No Matches
Public Member Functions
queen Class Reference

the queen piece class. More...

#include <queen.h>

Inheritance diagram for queen:
piece

Public Member Functions

 queen (bool _white, coordinates _coord)
 
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 possible
 
void print_piece () override
 print the piece to the standard output
 
void canonical_print_piece () override
 print the piece to the standard output in canonical form
 
- Public Member Functions inherited from piece
 piece (bool _white, coordinates _coord)
 the constructor for the piece class
 
bool is_possible (coordinates dest)
 verify if a move is within piece range
 
virtual bool is_possible_attack (coordinates dest)
 verify if a move is within piece attack range
 
virtual void move (coordinates dest, bool debug_info)
 called to move the piece
 
coordinates get_coord ()
 retrieve the piece's coordinates
 
bool get_color ()
 retrieve the piece's color
 
bool get_has_moved ()
 retrieve if the piece has already moved during the game
 
piece_type get_type ()
 retrieve the piece's type
 
virtual std::vector< coordinatesget_legals ()
 retrieve the piece's legal moves
 

Additional Inherited Members

- Protected Attributes inherited from piece
bool white
 
coordinates coord
 
std::vector< coordinateslegals
 
bool has_moved
 
piece_type type
 

Detailed Description

the queen piece class.

Definition at line 9 of file queen.h.

Constructor & Destructor Documentation

◆ queen()

queen::queen ( bool _white,
coordinates _coord )
inline

Definition at line 11 of file queen.h.

11 :
12 piece(_white,_coord)
13 {
15 for(int i = -7; i < 8; i++)
16 if(i!=0){
17 // Bishop moves
18 legals.push_back(coordinates(i,i));
19 legals.push_back(coordinates(i,-i));
20 // Rook moves
21 legals.push_back(coordinates(0,i));
22 legals.push_back(coordinates(i,0));
23 }
24 }
a class representing coordinates
Definition coordinates.h:5
piece_type type
Definition piece.h:17
piece(bool _white, coordinates _coord)
the constructor for the piece class
Definition piece.cc:8
std::vector< coordinates > legals
Definition piece.h:15
@ queen_type
Definition piece.h:8

Member Function Documentation

◆ canonical_print_piece()

void queen::canonical_print_piece ( )
overridevirtual

print the piece to the standard output in canonical form

Reimplemented from piece.

Definition at line 70 of file queen.cc.

70 {
71 if(piece::white){
72 std::cout << "wQ";
73 }else{
74 std::cout << "bQ";
75 }
76}
bool white
Definition piece.h:13

◆ needed_space()

void queen::needed_space ( coordinates dest,
std::vector< coordinates > * to_calculate )
overridevirtual

calculate a list of empty space coordinates needed for the move to be legal, assuming the move is possible

Parameters
destdestination coordinates
Returns
a vector containing all coordinates to be verified

Reimplemented from piece.

Definition at line 11 of file queen.cc.

11 {
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}
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

◆ print_piece()

void queen::print_piece ( )
overridevirtual

print the piece to the standard output

Reimplemented from piece.

Definition at line 61 of file queen.cc.

61 {
62 if(piece::white){
63 std::cout << "\u2655";
64 }else{
65 std::cout << "\u265B";
66 }
67}

The documentation for this class was generated from the following files: