///////////////////////////////////////////////////////////////////////////// // // EpdBinary.h : interface for compressed EPD classes // // Written by Thomas F. Mooney, III (tfm3@teleproc.com) // Copyright © 1999. // // This code may be used in compiled form in any way you desire. This // file may be redistributed unmodified by any means PROVIDING it is // not sold for profit without the authors written consent, and // providing that this notice and the authors name is included. If // the source code in this file is used in any commercial application // then acknowledgement must be made to the author of this file // (in whatever form you wish). // // This file is provided "as is" with no expressed or implied warranty. // The author accepts no liability if it causes any damage to your // computer, data, etc. // // Please report any bugs/anomalies/suggestions to the author via the // e-mail address listed above. // ///////////////////////////////////////////////////////////////////////////// #if !defined(EpdBinary_h_) #define EpdBinary_h_ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000> ///////////////////////////////////////////////////////////////////////////// // This file contains the definition of the EpdProcessor class. ///////////////////////////////////////////////////////////////////////////// #pragma warning (disable:4786) // Turn off innocuous warning message #include "ChessTypes.h" // include support classes // A few notes on the compression algorithm implemented by // EpdBinary. // // All positions compress to 192 bits = 24 bytes. // // The first 64 bits represent the board, one bit per square, // 0=empty, 1=occupied in EPD/FEN sequence a8,b8,...a7,b7.... // // The last 128 bits represent the pawns and pieces, 4 bits // per pawn/piece, positionally in EPD/FEN sequence. // // Unused bits are always zero. // // Each pawn/piece is represented by a 4 bit pattern. Some // of the patterns indicate additional information that must // be carried to complete the EPD. // // Pawn/piece bit patterns as follows: // // '0000' - black king // '1000' - white king (white to move) // '1111' - white king (black to move) // '0001' - black queen // '1001' - white queen // '0010' - black rook // '1010' - white rook // '0011' - black rook (may castle) // '1011' - white rook (may castle) // '0100' - black knight // '1100' - white knight // '0101' - black bishop // '1110' - white bishop // '0110' - black pawn // '1110' - white pawn // '0111' - en passant pawn // These values may be found in ChessTypes.h. They are in // byte array format because all of the work is done in byte // arrays with bit->byte and byte->bit routines at the front // and back end for simplicity. class EpdBinary { public: EpdBinary(); EpdBinary(const EpdBinary& OldEpd); EpdBinary(const char* OldEpdChar); EpdBinary(const EPD& StringEpd); EpdBinary(epd_solid &es, char *edata); ~EpdBinary(); EpdBinary& operator=(const EpdBinary& OldEpd); bool operator==(const EpdBinary& OldEpd); bool operator>(const EpdBinary& OldEpd); bool operator>=(const EpdBinary& OldEpd); bool operator<(const EpdBinary& OldEpd); bool operator<=(const EpdBinary& OldEpd); operator char*(); int GetPieceCount(); EPD GetEpd(); void *epd_goo(){return (void *) &e;} void SetCE(int ce) {e.ce = ce;} void SetACD(int acd) {e.acd = acd;} void SetPM(char *pm); void SetBM(char *bm); void SetAM(char *am); int SaveToFile(FILE *f); int ReadFromFile(FILE *f); int GetFromFile(epd_solid &es, char *edata, FILE *f); protected: private: void CompressString(const EPD& StringEpd); void ConstructorHelper(); epd_info e; public: protected: char m_Buffer[EPD_BINARY_LENGTH]; private: static const char EpdBinary::BitsOnInByte[256]; }; #endif // !defined(EpdBinary_h_)