private void CreateDefaultBoard() { _board = OthelloBoard.CreateStartingBoard(); }
static void ReadBook() { #if USE_TRANSPOSITION_TABLE StreamReader reader = null; try { reader = new StreamReader("book.txt"); } catch { // No opening book, oh well... return; } // Each line is a game, and looks like: +d3-c3+c4-e3+c2-b3+d2...-a5+a7-a8+b8-b7: -04 10 // -04 is the final score for black. 10 is always there and should be ignored for (int x = 0; ; x++) { string s = reader.ReadLine(); if (s == null) { break; } OthelloBoard board = OthelloBoard.CreateStartingBoard(); int i; i = s.LastIndexOf(':'); int val = int.Parse(s.Substring(i + 2, 3)); if (val < 0) { val -= 500; } else if (val > 0) { val += 500; } // Only use the first 10 moves to limit size for (i = 0; i < (10 * 3); i += 3) { if (s[i] == ':') { break; } OthelloMove move = new OthelloMove((s[i + 1] - 'a'), (s[i + 2] - '1')); board.PlayMove(move); board.FixUpCurrentPlayer(); _transpositionTable.AddEntry(board.GetHashCode(), 60 /*ply*/, (board.CurrentPlayer == SquareState.Black) ? val : -val, TranspositionTableElementType.Exact, -1, -1); move = null; } board.FixUpCurrentPlayer(); /* * int expectedVal = board.BlackSquares - board.WhiteSquares; * Debug.Assert(val == expectedVal); * Debug.Assert(board.GameOver); */ board = null; } reader.Close(); #endif }