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

the bishop piece class. More...

#include <bishop.h>

Inheritance diagram for bishop:
piece

Public Member Functions

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

Definition at line 9 of file bishop.h.

Constructor & Destructor Documentation

◆ bishop()

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

Definition at line 11 of file bishop.h.

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

Member Function Documentation

◆ canonical_print_piece()

void bishop::canonical_print_piece ( )
overridevirtual

print the piece to the standard output in canonical form

Reimplemented from piece.

Definition at line 41 of file bishop.cc.

41 {
42 if(piece::white){
43 std::cout << "wB";
44 }else{
45 std::cout << "bB";
46 }
47}
bool white
Definition piece.h:13

◆ needed_space()

void bishop::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 bishop.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 for(int i = 1; i < abs(diff_x); i++){
17 if(diff_x > 0){
18 coord_x = piece::coord.get_x() + i;
19 }else{
20 coord_x = piece::coord.get_x() - i;
21 }
22 if(diff_y > 0){
23 coord_y = piece::coord.get_y() + i;
24 }else{
25 coord_y = piece::coord.get_y() - i;
26 }
27 to_calculate->push_back(coordinates(coord_x,coord_y));
28 }
29}
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 bishop::print_piece ( )
overridevirtual

print the piece to the standard output

Reimplemented from piece.

Definition at line 32 of file bishop.cc.

32 {
33 if(piece::white){
34 std::cout << "\u2657";
35 }else{
36 std::cout << "\u265D";
37 }
38}

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