aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorymherklotz <ymherklotz@gmail.com>2017-01-15 19:44:15 +0000
committerymherklotz <ymherklotz@gmail.com>2017-01-15 19:44:15 +0000
commit1f138d96ab7f517e7842710ef3428f67a2965877 (patch)
tree4070a934b4cf8d3040e48a50dc5e0991058fa136
parenta5bc94a36fe37fb20eba61516da3b6b58208537b (diff)
downloadChessAI-1f138d96ab7f517e7842710ef3428f67a2965877.tar.gz
ChessAI-1f138d96ab7f517e7842710ef3428f67a2965877.zip
creating the board
-rw-r--r--include/chess_board.hpp42
-rw-r--r--include/chess_piece.hpp19
-rw-r--r--src/bishop.cpp1
-rw-r--r--src/chess_board.cpp34
-rw-r--r--src/chess_piece.cpp1
-rw-r--r--src/king.cpp3
-rw-r--r--src/knight.cpp1
-rw-r--r--src/pawn.cpp1
-rw-r--r--src/queen.cpp1
-rw-r--r--src/rook.cpp1
-rw-r--r--src/test_bench.cpp6
11 files changed, 108 insertions, 2 deletions
diff --git a/include/chess_board.hpp b/include/chess_board.hpp
new file mode 100644
index 0000000..fef1f69
--- /dev/null
+++ b/include/chess_board.hpp
@@ -0,0 +1,42 @@
+/*
+ *
+ * author: Yann Herklotz
+ * username: ymherklotz
+ * email: ymherklotz@gmail.com
+ * date created: 14/01/17
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Chess Board class that will have all the chess pieces on it
+ *
+ */
+
+#ifndef YMH_CHESS_BOARD_HPP
+#define YMH_CHESS_BOARD_HPP
+
+#include "chess_piece.hpp"
+
+#include <vector>
+#include <memory>
+
+namespace ymhChessAI {
+typedef std::vector<std::unique_ptr<ChessPiece> >::iterator boardIterator;
+typedef std::vector<std::unique_ptr<ChessPiece> > boardVector;
+typedef std::unique_ptr<ChessPiece> chessPiecePtr;
+
+class ChessBoard {
+public:
+ ChessBoard();
+ ChessBoard(const ChessBoard& other) = default;
+ virtual ~ChessBoard() = default;
+
+ void printBoard();
+protected:
+private:
+ static const unsigned CHESS_BOARD_SIZE = 64;
+
+ boardVector board;
+};
+}
+
+#endif
diff --git a/include/chess_piece.hpp b/include/chess_piece.hpp
index 60b6fe5..ce6ca5c 100644
--- a/include/chess_piece.hpp
+++ b/include/chess_piece.hpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
@@ -54,7 +55,7 @@ protected:
};
-// King class that provides the class for the king
+// King class
class King : public ChessPiece {
public:
@@ -68,6 +69,9 @@ protected:
private:
};
+
+// Queen class
+
class Queen : public ChessPiece {
public:
Queen();
@@ -80,6 +84,9 @@ protected:
private:
};
+
+// Rook class
+
class Rook : public ChessPiece {
public:
Rook();
@@ -93,6 +100,8 @@ private:
};
+// Bishop class
+
class Bishop : public ChessPiece {
public:
Bishop();
@@ -105,6 +114,9 @@ protected:
private:
};
+
+// Knight class
+
class Knight : public ChessPiece {
public:
Knight();
@@ -117,6 +129,9 @@ protected:
private:
};
+
+// Pawn class
+
class Pawn : public ChessPiece {
public:
Pawn();
@@ -128,6 +143,6 @@ public:
protected:
private:
};
-};
+}
#endif
diff --git a/src/bishop.cpp b/src/bishop.cpp
index 4894be5..849db19 100644
--- a/src/bishop.cpp
+++ b/src/bishop.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/chess_board.cpp b/src/chess_board.cpp
new file mode 100644
index 0000000..30c8aff
--- /dev/null
+++ b/src/chess_board.cpp
@@ -0,0 +1,34 @@
+/*
+ *
+ * author: Yann Herklotz
+ * username: ymherklotz
+ * email: ymherklotz@gmail.com
+ * date created: 14/01/17
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Chess Board class implementation
+ *
+ */
+
+#include "chess_board.hpp"
+#include <iostream>
+using namespace ymhChessAI;
+
+
+ChessBoard::ChessBoard() {
+ board.reserve(CHESS_BOARD_SIZE);
+
+ for(auto&& piece : board)
+ piece = std::unique_ptr<ChessPiece>(new King);
+
+ // for(unsigned i = 0; i < CHESS_BOARD_SIZE; ++i)
+ // board.emplace_back(new King);
+}
+
+void ChessBoard::printBoard() {
+ for(auto&& piece : board) {
+ piece->move(1, 2);
+ std::cout << "Hello" << std::endl;
+ }
+}
diff --git a/src/chess_piece.cpp b/src/chess_piece.cpp
index ee307e2..626377e 100644
--- a/src/chess_piece.cpp
+++ b/src/chess_piece.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/king.cpp b/src/king.cpp
index 8e8a6b9..1d297d3 100644
--- a/src/king.cpp
+++ b/src/king.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
@@ -11,6 +12,7 @@
*/
#include "chess_piece.hpp"
+#include <iostream>
using namespace ymhChessAI;
@@ -22,4 +24,5 @@ King::King(const int& x, const int& y, const Colour& colour) : ChessPiece(x, y,
}
void King::move(const int& x, const int& y) {
+ std::cout << "This is the king" << std::endl;
}
diff --git a/src/knight.cpp b/src/knight.cpp
index 5c2a946..6b7f5ac 100644
--- a/src/knight.cpp
+++ b/src/knight.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/pawn.cpp b/src/pawn.cpp
index e81959f..1374886 100644
--- a/src/pawn.cpp
+++ b/src/pawn.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/queen.cpp b/src/queen.cpp
index d685548..897237a 100644
--- a/src/queen.cpp
+++ b/src/queen.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/rook.cpp b/src/rook.cpp
index cba38a9..cd72029 100644
--- a/src/rook.cpp
+++ b/src/rook.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
diff --git a/src/test_bench.cpp b/src/test_bench.cpp
index 474c53b..ab23d6c 100644
--- a/src/test_bench.cpp
+++ b/src/test_bench.cpp
@@ -3,6 +3,7 @@
* author: Yann Herklotz
* username: ymherklotz
* email: ymherklotz@gmail.com
+ * date created: 13/01/17
*
* -----------------------------------------------------------------------------
*
@@ -12,6 +13,7 @@
#include "chess_tester.hpp"
#include "chess_piece.hpp"
+#include "chess_board.hpp"
#include <iostream>
@@ -22,6 +24,10 @@ int main(int argc, char **argv) {
cout << "Program name: " << argv[0] << endl;
cout << "Arguments: " << argc - 1 << endl;
+ ChessBoard cb;
+
+ cb.printBoard();
+
cout << endl << "====== Executed Successfully ======" << endl;
return 0;