BlueBubble 1.0
A recommendation algorithm for movies based on a Netlfix database
Loading...
Searching...
No Matches
pawn.h
Go to the documentation of this file.
1#ifndef PAWN
2#define PAWN
5#include "piece.h"
6#include <vector>
7
9class pawn : public piece{
10 private:
11 // The standard moves and the attack moves all at once
12 std::vector<coordinates> possible_legals;
13 public:
14 pawn(bool _white, coordinates _coord):
15 piece(_white,_coord)
16 {
18 int direction = 0;
19 if(piece::white){
20 direction = 1;
21 }else{
22 direction = -1;
23 }
24 // The attack moves list is managed in the overrided is_possible_attack function.
25 legals.push_back(coordinates(0,2*direction));
26 possible_legals.push_back(coordinates(0,2*direction));
27 legals.push_back(coordinates(0,direction));
28 possible_legals.push_back(coordinates(0,direction));
29 // Attack moves in possible_legals
30 possible_legals.push_back(coordinates(1,direction));
31 possible_legals.push_back(coordinates(-1,direction));
32 }
33 void needed_space(coordinates dest, std::vector<coordinates> *to_calculate) override;
34 void print_piece() override;
35 void canonical_print_piece() override;
36 void move(coordinates dest, bool debug_info) override;
37 bool is_possible_attack(coordinates dest) override;
38 // We need to override because the pawn has attack moves that differs from legals (standard) move
39 std::vector<coordinates> get_legals() override;
40};
41
42#endif
a class representing coordinates
Definition coordinates.h:5
the pawn piece class.
Definition pawn.h:9
bool is_possible_attack(coordinates dest) override
verify if the dest position is a valid attack move. The pawn need a special overrided function.
Definition pawn.cc:70
pawn(bool _white, coordinates _coord)
Definition pawn.h:14
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 pawn.cc:11
void canonical_print_piece() override
print the piece to the standard output in canonical form
Definition pawn.cc:40
std::vector< coordinates > possible_legals
Definition pawn.h:12
void print_piece() override
print the piece to the standard output
Definition pawn.cc:31
void move(coordinates dest, bool debug_info) override
called to move the pawn
Definition pawn.cc:51
std::vector< coordinates > get_legals() override
retrieve the piece's legal moves
Definition pawn.cc:81
a generic piece class. white is a boolean indicating the piece's color. legals is a vector indicating...
Definition piece.h:11
piece_type type
Definition piece.h:17
bool white
Definition piece.h:13
std::vector< coordinates > legals
Definition piece.h:15
@ pawn_type
Definition piece.h:8