aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2017-01-23 15:18:05 +0000
committerymherklotz <ymherklotz@gmail.com>2017-01-23 15:18:05 +0000
commit7ec074f67ae29a792e718fc48f7817b3a77b81ad (patch)
tree73afe11e47426139f378f5140a045571d39efcd8
parent43910de3a8899b332e697ba210436be70e6a6f7c (diff)
downloadChessAI-7ec074f67ae29a792e718fc48f7817b3a77b81ad.tar.gz
ChessAI-7ec074f67ae29a792e718fc48f7817b3a77b81ad.zip
Created a seperate filemakeoverfinish_parser
-rw-r--r--include/board_state_parser.hpp2
-rw-r--r--include/chess_board.hpp2
-rw-r--r--include/chess_constants.hpp28
-rw-r--r--include/chess_piece.hpp5
-rw-r--r--src/board_state_parser.cpp3
-rw-r--r--src/chess_board.cpp8
-rw-r--r--src/chess_piece.cpp2
-rw-r--r--src/pawn.cpp8
8 files changed, 47 insertions, 11 deletions
diff --git a/include/board_state_parser.hpp b/include/board_state_parser.hpp
index d98ac4f..b054007 100644
--- a/include/board_state_parser.hpp
+++ b/include/board_state_parser.hpp
@@ -36,8 +36,6 @@ public:
static std::string getStateFromLine(const std::string& str);
protected:
private:
- static const std::size_t BOARD_SIZE = 64;
-
boardStateData boardStateVector;
std::ifstream boardFile;
};
diff --git a/include/chess_board.hpp b/include/chess_board.hpp
index e5e4d7b..fdaf46e 100644
--- a/include/chess_board.hpp
+++ b/include/chess_board.hpp
@@ -34,8 +34,6 @@ public:
bool printBoard();
protected:
private:
- static const std::size_t BOARD_SIZE = 64;
-
boardVector board;
};
}
diff --git a/include/chess_constants.hpp b/include/chess_constants.hpp
new file mode 100644
index 0000000..cb50a37
--- /dev/null
+++ b/include/chess_constants.hpp
@@ -0,0 +1,28 @@
+/*
+ *
+ * author: Yann Herklotz
+ * username: ymherklotz
+ * email: ymherklotz@gmail.com
+ * date created: 23/01/17
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Chess Piece class with header for all the pieces as well that inherit
+ * from the Chess Piece class.
+ *
+ */
+
+#ifndef YMH_CHESS_CONSTANTS
+#define YMH_CHESS_CONSTANTS
+
+class ChessConstants {
+public:
+ static const unsigned BOARD_SIZE = 64;
+
+ static const unsigned WHITE_PAWN_ROW = 6;
+ static const unsigned BLACK_PAWN_ROW = 1;
+protected:
+private:
+};
+
+#endif
diff --git a/include/chess_piece.hpp b/include/chess_piece.hpp
index 5b2c1c2..1838af8 100644
--- a/include/chess_piece.hpp
+++ b/include/chess_piece.hpp
@@ -37,7 +37,8 @@ typedef unsigned int boardPosition;
enum class Colour {
White,
- Black
+ Black,
+ None
};
@@ -143,7 +144,7 @@ private:
class EmptyPiece : public ChessPiece {
public:
EmptyPiece();
- EmptyPiece(const int& x, const int& y, const Colour& colour);
+ EmptyPiece(const int& x, const int& y);
virtual void move(const int& x, const int& y);
protected:
diff --git a/src/board_state_parser.cpp b/src/board_state_parser.cpp
index 5ff6bf3..288a491 100644
--- a/src/board_state_parser.cpp
+++ b/src/board_state_parser.cpp
@@ -12,6 +12,7 @@
*/
#include "board_state_parser.hpp"
+#include "chess_constats.hpp"
using namespace ymhChessAI;
@@ -29,7 +30,7 @@ BoardStateParser::~BoardStateParser() {
void BoardStateParser::populateBoardState() {
std::string currentLine;
- boardStateVector.reserve(BOARD_SIZE);
+ boardStateVector.reserve(ChessConstants::BOARD_SIZE);
if(!boardFile.is_open())
throw "Error: Can't open file";
diff --git a/src/chess_board.cpp b/src/chess_board.cpp
index 051decd..e0967ad 100644
--- a/src/chess_board.cpp
+++ b/src/chess_board.cpp
@@ -12,18 +12,20 @@
*/
#include "chess_board.hpp"
+#include "chess_constants.hpp"
+
#include <iostream>
using namespace ymhChessAI;
ChessBoard::ChessBoard() {
- for(unsigned i = 0; i < BOARD_SIZE; ++i)
+ for(unsigned i = 0; i < ChessConstants::BOARD_SIZE; ++i)
board.emplace_back(new EmptyPiece);
}
bool ChessBoard::populateBoard() {
- for(auto&& piece : board)
+ for(auto && piece : board)
piece = chessPiecePtr(new Knight);
return true;
}
@@ -31,7 +33,7 @@ bool ChessBoard::populateBoard() {
bool ChessBoard::printBoard() {
int i = 0;
- for(auto&& piece : board) {
+ for(auto && piece : board) {
std::cout << i << " ";
piece->move(1, 2);
++i;
diff --git a/src/chess_piece.cpp b/src/chess_piece.cpp
index d4d14e6..33ce34f 100644
--- a/src/chess_piece.cpp
+++ b/src/chess_piece.cpp
@@ -25,7 +25,7 @@ ChessPiece::ChessPiece(const int& x, const int& y, const Colour& colour) : m_x(x
EmptyPiece::EmptyPiece() : ChessPiece() {
}
-EmptyPiece::EmptyPiece(const int& x, const int& y, const Colour& colour) : ChessPiece(x, y, colour) {
+EmptyPiece::EmptyPiece(const int& x, const int& y) : ChessPiece(x, y, Colour::None) {
}
void EmptyPiece::move(const int& x, const int& y) {
diff --git a/src/pawn.cpp b/src/pawn.cpp
index 1374886..458b980 100644
--- a/src/pawn.cpp
+++ b/src/pawn.cpp
@@ -12,6 +12,7 @@
*/
#include "chess_piece.hpp"
+#include "chess_constants.hpp"
using namespace ymhChessAI;
@@ -23,4 +24,11 @@ Pawn::Pawn(const int& x, const int& y, const Colour& colour) : ChessPiece(x, y,
}
void Pawn::move(const int& x, const int& y) {
+ if(m_colour == Colour::White) {
+ if(m_y == ChessConstants::WHITE_PAWN_ROW) {
+ }
+ } else {
+ if(m_y == ChessConstants::BLACK_PAWN_ROW) {
+ }
+ }
}