-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovement.h
79 lines (65 loc) · 2.22 KB
/
Movement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef MOVEMENT_H_
#define MOVEMENT_H_
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string.h>
#include "gamestate.h"
//forward declaration
class GameState;
struct MoveCoord{
int xStart;
int yStart;
int xEnd;
int yEnd;
};
//TODO: optimize the usage of vectors
class Move{
public:
int m_pieceMoved;
int m_pieceTaken;
int m_start_x;
int m_start_y;
int m_end_x;
int m_end_y;
private:
public:
//constructor
Move(const GameState &gamestate, MoveCoord moveCoord);
//constructor overload
Move();
//check if move is in legalMoves
bool isLegal(std::vector<Move> const &legalMoves);
//debug function to print the move
void printMove() const;
//closes the move
void close();
};
//makes a move
void makeMove(GameState &gamestate, Move move);
//undoes the latest move
void undoMove(GameState &gamestate);
//gets the valid moves for the current gamestate
void getLegalMoves(std::vector<Move> &legalMoves, std::vector<Move> &theoreticalMoves, const GameState &gamestate);
//gets the theoretical moves of each piece
void getTheoreticalMoves(std::vector<Move> &theoreticalMoves, const GameState &gamestate);
//get moves of pawns
void getPawnMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//get moves of knights
void getKnightMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//get moves of rooks
void getRookMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//get moves of bishops
void getBishopMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//get moves of Queens
void getQueenMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//get moves of Kings
void getKingMoves(std::vector<Move> &legalMoves, const GameState &gamestate, int x, int y);
//check if current gamestate is in check and if certain pieces are pinned
void checkForPinsAndChecks(const GameState &gamestate);
//return the type of a piece as int
int getPieceType(const GameState &gamestate, int x, int y);
//checks if the game is over
void CheckmateandStalemate(const std::vector<Move> &legalMoves, const GameState &gamestate);
#endif