1 #ifndef __OPENINGBOOK_H__ 2 #define __OPENINGBOOK_H__ 3 4 /* 5 * OpeningBook.h (c) Noah Roberts 2003-03-24 6 * In charge of giving the engine some hints on what to play in the beginning of the game. 7 * Provides adiquate opening play since the engine is unable to strategize. Also gives play 8 * that is not redundant - ie it won't always respond with the same move every damn time. 9 */ 10 11 class Board; 12 class Move; 13 14 #include <map> 15 #include <vector> 16 #include <string> 17 #include <cstdlib> 18 #include <ctime> 19 20 //typedef unsigned int u_int32; 21 typedef unsigned short u_int16; 22 23 typedef std::vector< u_int16 > BookEntry; 24 typedef std::map< std::string, BookEntry > Book; 25 26 class OpeningBook 27 { 28 Book *bookContents; 29 bool validBook; 30 void read(std::string filename); 31 u_int16 selectMove(BookEntry entry); 32 public: OpeningBook(std::string filename)33 OpeningBook(std::string filename) { bookContents = new Book; read(filename); srand(time(NULL)); } ~OpeningBook()34 ~OpeningBook() { delete bookContents; } 35 u_int16 getMove(Board *board); 36 37 bool operator!() { return validBook; } valid()38 bool valid() { return validBook; } 39 }; 40 41 #endif /* __OPENINGBOOK_H__ */ 42