-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosition.h
More file actions
95 lines (74 loc) · 2.97 KB
/
Copy pathPosition.h
File metadata and controls
95 lines (74 loc) · 2.97 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// Created by Julius on 28/02/2024.
//
#ifndef UNTITLED_POSITION_H
#define UNTITLED_POSITION_H
#include <cstdint>
#include <array>
#include <vector>
#include <stack>
#include "Helper.h"
namespace Engine {
struct irreversibleAspect{
bool whiteKingsideCastle;
bool whiteQueensideCastle;
bool blackKingsideCastle;
bool blackQueensideCastle;
int enPassantTarget = 0;
};
class Position {
public:
Position(std::string fen);
bool whiteKingsideCastle = true;
bool whiteQueensideCastle = true;
bool blackKingsideCastle = true;
bool blackQueensideCastle = true;
int enPassantTarget = 0;
bool whiteToMove = true;
std::array<Bitboard,13> pieceOccupancy;
std::array<Piece,64> pieceNames;
Bitboard occupancy = 0;
Bitboard whiteOccupancy = 0; //color occupancy not including kings???
Bitboard blackOccupancy = 0;
Bitboard* friendlyOccupancy = &whiteOccupancy; // does this work? remember to change when make move
Bitboard* enemyOccupancy = &blackOccupancy;
void draw();
void debugDraw(std::string mode);
void loadFromFEN(const std::string& fen);
void makeMove(Move move);
void unMakeMove(Move move);
bool equals(const Position& position);
Position(const Position& other){
whiteKingsideCastle = other.whiteKingsideCastle;
whiteQueensideCastle = other.whiteQueensideCastle;
blackKingsideCastle = other.blackKingsideCastle;
blackQueensideCastle = other.blackQueensideCastle;
enPassantTarget = other.enPassantTarget;
whiteToMove = other.whiteToMove;
pieceOccupancy = other.pieceOccupancy;
pieceNames = other.pieceNames;
occupancy = other.occupancy;
whiteOccupancy = other.whiteOccupancy;
blackOccupancy = other.blackOccupancy;
pieceOccupancy = other.pieceOccupancy;
pieceNames = other.pieceNames;
friendlyOccupancy = whiteToMove ? &whiteOccupancy : &blackOccupancy;
enemyOccupancy = whiteToMove ? &blackOccupancy : &whiteOccupancy;
}
private:
std::stack<irreversibleAspect> irreversibleAspectStack;
Piece promotionCodeToPiece(int code);
void addPiece(Piece piece, int x, int y);
void capturePiece(int from, int to);
void unCapturePiece(int from, int to, Piece piece);
void capturePieceEP(int from, int to);
void unCapturePieceEP(int from, int to, Piece piece);
void movePiece(int from, int to);
void unMovePiece(int from, int to);
void capturePiecePromote(int from, int to, int code);
void unCapturePiecePromote(int from, int to,int code, Engine::Piece captured);
void movePiecePromote(int from, int to, int code);
void unMovePiecePromote(int from, int to, int code);
};
} // Engine
#endif //UNTITLED_POSITION_H