Nicolas Winkler 8 سال پیش
والد
کامیت
7a09bae7df
3فایلهای تغییر یافته به همراه125 افزوده شده و 0 حذف شده
  1. 58 0
      src/Board.cpp
  2. 67 0
      src/Board.h
  3. BIN
      src/Board.o

+ 58 - 0
src/Board.cpp

@@ -0,0 +1,58 @@
+#include "Board.h"
+#include <string>
+
+using namespace chessy;
+
+
+void Board::resetBoard(void)
+{
+    whitePawns =    0x000000000000FF00;
+    whiteRooks =    0x0000000000000081;
+    whiteKnights =  0x0000000000000042;
+    whiteBishops =  0x0000000000000024;
+    whiteQueens =   0x0000000000000010;
+    whiteKing =     0x0000000000000008;
+
+    blackPawns =    0x00FF000000000000;
+    blackRooks =    0x8100000000000000;
+    blackKnights =  0x4200000000000000;
+    blackBishops =  0x2400000000000000;
+    blackQueens =   0x1000000000000000;
+    blackKing =     0x0800000000000000;
+}
+
+
+Bitboard Board::getWhites(void) const
+{
+    return
+        whitePawns |
+        whiteRooks |
+        whiteKnights |
+        whiteBishops |
+        whiteQueens |
+        whiteKing;
+}
+
+
+Bitboard Board::getBlacks(void) const
+{
+    return
+        blackPawns |
+        blackRooks |
+        blackKnights |
+        blackBishops |
+        blackQueens |
+        blackKing;
+}
+
+
+Bitboard Board::getOccupied(void) const
+{
+    return getWhites() | getBlacks();
+}
+
+
+Bitboard Board::getFree(void) const
+{
+    return ~getOccupied();
+}

+ 67 - 0
src/Board.h

@@ -0,0 +1,67 @@
+#ifndef CHESSY_BOARD_H
+#define CHESSY_BOARD_H
+
+#include "BitBoard.h"
+
+namespace chessy
+{
+    class Board;
+}
+
+
+class chessy::Board
+{
+    Bitboard whitePawns;
+    Bitboard whiteRooks;
+    Bitboard whiteKnights;
+    Bitboard whiteBishops;
+    Bitboard whiteQueens;
+    Bitboard whiteKing;
+
+    Bitboard blackPawns;
+    Bitboard blackRooks;
+    Bitboard blackKnights;
+    Bitboard blackBishops;
+    Bitboard blackQueens;
+    Bitboard blackKing;
+
+public:
+    Board(void) = default;
+    Board(const Board&) = default;
+    ~Board(void) = default;
+
+    /*!
+     * resets the board to the chess starting position.
+     */
+    void resetBoard(void);
+
+    /*!
+     * \return
+     *      a bitboard where every field occupied by a white piece
+     *      is 1, every free field 0
+     */
+    Bitboard getWhites(void) const;
+
+    /*!
+     * \return
+     *      a bitboard where every field occupied by a black piece
+     *      is 1, every free field 0
+     */
+    Bitboard getBlacks(void) const;
+
+    /*!
+     * \return
+     *      a bitboard where every field occupied by any piece
+     *      is 1, every free field 0
+     */
+    Bitboard getOccupied(void) const;
+
+    /*!
+     * \return
+     *      a bitboard where every field occupied by any piece
+     *      is 0, every free field 1
+     */
+    Bitboard getFree(void) const;
+};
+
+#endif // CHESSY_BOARD_H

BIN
src/Board.o