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

the rook piece class. More...

#include <rook.h>

Inheritance diagram for rook:
piece

Public Member Functions

 rook (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 rook piece class.

Definition at line 9 of file rook.h.

Constructor & Destructor Documentation

◆ rook()

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

Definition at line 11 of file rook.h.

11 :
12 piece(_white,_coord)
13 {
15 for(int i = -7; i < 8; i++)
16 if(i!=0){
17 legals.push_back(coordinates(0,i));
18 legals.push_back(coordinates(i,0));
19 }
20 }
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
@ rook_type
Definition piece.h:8

Member Function Documentation

◆ canonical_print_piece()

void rook::canonical_print_piece ( )
overridevirtual

print the piece to the standard output in canonical form

Reimplemented from piece.

Definition at line 48 of file rook.cc.

48 {
49 if(piece::white){
50 std::cout << "wR";
51 }else{
52 std::cout << "bR";
53 }
54}
bool white
Definition piece.h:13

◆ needed_space()

void rook::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 rook.cc.

11 {
12 if(dest.get_x() > piece::coord.get_x()){
13 //Moving right
14 for(int i = piece::coord.get_x() + 1; i < dest.get_x(); i++){
15 to_calculate->push_back(coordinates(i,piece::coord.get_y()));
16 }
17 }
18 if(dest.get_x() < piece::coord.get_x()){
19 //Moving left
20 for(int i = piece::coord.get_x() - 1; i > dest.get_x(); i--){
21 to_calculate->push_back(coordinates(i,piece::coord.get_y()));
22 }
23 }
24 if(dest.get_y() > piece::coord.get_y()){
25 //Moving right
26 for(int i = piece::coord.get_y() + 1; i < dest.get_y(); i++){
27 to_calculate->push_back(coordinates(piece::coord.get_x(),i));
28 }
29 }
30 if(dest.get_y() < piece::coord.get_y()){
31 //Moving left
32 for(int i = piece::coord.get_y() - 1; i > dest.get_y(); i--){
33 to_calculate->push_back(coordinates(piece::coord.get_x(),i));
34 }
35 }
36}
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 rook::print_piece ( )
overridevirtual

print the piece to the standard output

Reimplemented from piece.

Definition at line 39 of file rook.cc.

39 {
40 if(piece::white){
41 std::cout << "\u2656";
42 }else{
43 std::cout << "\u265C";
44 }
45}

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