Justin

CTG Specifications (Unofficial)

Dec 26th, 2017
175
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.08 KB | None | 0 0
  1. The CTG (Chessbase book) format
  2. Unofficial specification, version 0.2.
  3. Author: Anonymous
  4.  
  5. 0. Structure
  6.  
  7. Each Chessbase book consists of four files:
  8.  
  9. - The .INI file, which contains some auxilliary information. Being a text
  10. file, it's mostly self-explanatory and will not be treated here.
  11. - The .CTG file, which contains all the real data. This is described in
  12. chapter 1.
  13. - The .CTB file, which is unknown but conjectured to be some kind of bitmap
  14. over free pages in the .CTG file. Only described very loosely, in chapter
  15. 2.
  16. - The .CTO file, which contains a lookup table into the CTG file for fast
  17. lookups. The format of this is only partially known, but is described in
  18. chapter 3.
  19.  
  20. 1. The CTG file
  21.  
  22. 1.1. General conventions
  23.  
  24. The following conventions apply:
  25.  
  26. - All integers are stored in big-endian format, whether they are 2, 3 or 4
  27. bytes long.
  28. - Whenever a length of a block is stored, the number generally includes the
  29. length byte itself.
  30. - There is no alignment of values, except that pages are aligned on
  31. 4096-byte boundaries.
  32.  
  33. The CTG file is divided into 4096 byte pages.
  34.  
  35. 1.2. Header page
  36.  
  37. The first page is the header page which contains some general information
  38. about the file:
  39.  
  40. - At offset 28, a 4-byte value is stored, denoting the number of games
  41. "stored" in the field. There is also some other (unknown) data in the
  42. first 32 bytes.
  43. - At offset 1024 (0x400), 32 unknown bytes are stored.
  44. - At offset 2048 (0x800), 32 unknown bytes are stored.
  45.  
  46. The other bytes in the header page are unused.
  47.  
  48. 1.3. Data pages
  49.  
  50. After the first page, all the other pages store positions. The first data
  51. page (starting at offset 4096) is denoted "page 0", the next is "page 1",
  52. etc.. The page numbers are used in the CTO file.
  53.  
  54. In general, what is looked up in the CTG format is positions, although
  55. possible moves from each position are also stored. This enables the format to
  56. deal with transpositions. Each page stores one or more positions in random
  57. order. It is not known how Chessbase decides what page to put each position
  58. in, but it is conjectured to be based on hash value (see the section about
  59. the CTO format below).
  60.  
  61. Each data page starts with a brief header:
  62.  
  63. - At offset 0 in the page, a 2-byte integer is stored, telling the number
  64. of positions stored in the page.
  65. - At offset 2, a 2-byte integer is stored, giving the number of bytes
  66. stored in the page (including the four header bytes). Note that after
  67. this, there may be random junk data, so be sure to stop reading the
  68. page after reaching the given number of bytes.
  69.  
  70. At offset 4, the first position entry starts. Position entries then follow
  71. directly after each other until the end of the page (ie. the number of bytes
  72. specified in the header).
  73.  
  74. 1.4. Position storage
  75.  
  76. Note that this specification distinguished between position entries and
  77. positions. A position is a chess position, with information about castling
  78. rights and en passant move. (The CTG format does not store any information
  79. about the 50-move rule or move history.) A position entry contains a position
  80. and book information about the position:
  81.  
  82. The position entry contains a position, the book moves, and some information
  83. associated with the position. (In general, most of the information that seem
  84. to be associated with moves in the Chessbase GUI actually stems from looking
  85. it up in the resulting position.)
  86.  
  87. 1.4.1. Symmetry
  88.  
  89. Every position is stored as if white is to move. If black is to move,
  90. invert the white/black pieces and flip the board vertically (so a1 <-> a8, a2
  91. <-> a7, etc.). Due to the symmetry of chess this will give the same result.
  92.  
  93. After this inversion (if any), check if the white king is in the left half
  94. of the board (columns one through four). If it is, and neither side has any
  95. castling rights remaining, flip the board horizontally (so a1 <-> h1,
  96. a2 <-> h2, etc.). Naturally, the en passant square is also flipped.
  97.  
  98. 1.4.2. Header byte
  99.  
  100. Each position entry begins with a header byte:
  101.  
  102. - The lower five bits (x & 0x1f) describe the length of the position
  103. itself, in bytes, including the header byte.
  104. - If the sixth bit (x & 0x20) is set, the position contains en passant
  105. information. This happens if and only if an en passant capture is
  106. possible.
  107. - If the seventh bit (x & 0x40) is set, the position contains castling
  108. information. If not, neither side can castle. (The bit is never set
  109. if neither side can castle.)
  110. - The eighth bit (x & 0x80) is unused.
  111.  
  112. 1.4.3. Chess board
  113.  
  114. After the header byte, the position itself is encoded. The position is stored
  115. using a Huffman encoding and as such uses a variable number of bits. The
  116. bit-packing convention is the usual one, with the first bit in the MSB (0x80)
  117. of the first byte, any any excess bits at the end being set to zero,
  118.  
  119. The position is encoded starting at the a1 square, then the a2 square, up to
  120. a8, b1, b2, etc.. Each square is encoded as follows:
  121.  
  122. 0 Empty square
  123. 11c Pawn (c=1 means black, c=0 means white)
  124. 1011c Rook
  125. 1010c Bishop
  126. 1001c Knight
  127. 10001c Queen
  128. 10000c King
  129.  
  130. 1.4.4. Alignment padding bits
  131.  
  132. At this point, padding bits may be inserted. The rules are somewhat complex:
  133. First, if the position ended exactly on a byte, there are no castling rights
  134. and no en passant column, insert a full zero byte at this point, and ignore
  135. the rest of this section.
  136.  
  137. Otherwise, define a number N as follows, based on whether there is an en
  138. passant square (E=1, otherwise E=0) and if castling is stored (C=1, otherwise
  139. C=0):
  140.  
  141. E=0, C=0: N=8
  142. E=0, C=1: N=4
  143. E=1, C=0: N=3
  144. E=1, C=1: N=7
  145.  
  146. If there are not exactly N bits left in the current byte, insert zero bits
  147. as needed (possibly as many as seven) until there is. This alignment scheme
  148. ensures that the last data bit ends exactly on a byte boundary.
  149.  
  150. 1.4.5. En passant column
  151.  
  152. If en passant information is stored (see 1.4.2), it follows (still bitpacked)
  153. immediately after the padding. Three bits store the column, where 000=a,
  154. 001=b, 010=c, etc..
  155.  
  156. 1.4.6. Castling rights
  157.  
  158. If castling rights are stored (see 1.4.2), it follows (still bitpacked) at
  159. this point. The castling rights are stored as four bits, storing in turn
  160. black kingside castling rights (1 = can castle, 0 = can not castle), black
  161. queenside castling rights, and then the same for white.
  162.  
  163. 1.4.7. Position end
  164.  
  165. At this point, the bit-packing ends. As mentioned in section 1.4.4, this
  166. should be exactly on a byte boundary, so no further padding should be needed.
  167.  
  168. 1.4.8. Book moves
  169.  
  170. After the position, any book moves (excluding unplayed transpositions) are
  171. stored. First, there is a header byte telling the number bytes used for book
  172. moves (including the header byte itself). Each move is stored in two bytes,
  173. and as such the header byte contains the value (2 * the number of moves) + 1.
  174.  
  175. The first byte of each move contains the move itself, and the second byte
  176. contains the move annotation, if any. The encoding of moves is slightly
  177. unusual -- in general, a look-up table is needed to decode the move
  178. information. Every possible byte can then be looked up into the combination
  179. (piece, relative movement).
  180.  
  181. The "piece" is in general something like "knight 2". Here, the board is
  182. searched for a white piece of the appropriate type in the same ordering as
  183. the board storage: If a white knight is on a1 it is always "knight 1" (since
  184. no squares are before a1 in this ordering).
  185.  
  186. The "relative movement" is the number of squares the piece is to move from
  187. its current position, for instance "two squares forward and one to the right"
  188. for a typical knight move. Note that the board is taken to wrap around on all
  189. four sides, so "forward seven squares" is exactly the same as "backwards one
  190. square" and will be encoded using the same byte. Long and short castling have
  191. their own bytes. (It is not known whether the format can represent castling
  192. in Chess960.)
  193.  
  194. Note that in this encoding, some legal but obscure moves can not be stored.
  195. In particular, promotions are automatically assumed to be to queen, so an
  196. underpromotion can simply not be stored. Also, there are no moves for "queen
  197. 5" or above, so if there are more than four queens on the board, moves for
  198. the fifth can not be entered. (In the case of underpromotion, however, the
  199. GUI actually stores the position as "pawn N forward one square" as usual, but
  200. when trying to look up the position later, it cannot find a position with a
  201. queen on the 8th rank, and thus will simply hide the move in the GUI.) In
  202. general, this should not be a problem for an opening book.
  203.  
  204. An incomplete table of move encoding follows. This encompasses all possible
  205. moves for the sixteen (white) pieces that are initially found on a chess
  206. board, as well as for an extra queen, which should be sufficient for most
  207. books, especially as underpromotion is not supported. A later version may
  208. include the moves for queen 3, rook 3, etc..
  209.  
  210. 0x00: Pawn 5 f1 r1
  211. 0x01: Knight 2 b1 l2
  212. 0x03: Queen 2 r2
  213. 0x04: Pawn 2 f1
  214. 0x05: Queen 1 f1
  215. 0x06: Pawn 4 f1 l1
  216. 0x08: Queen 2 r4
  217. 0x09: Bishop 2 f6 r6
  218. 0x0a: King b1
  219. 0x0c: Pawn 1 f1 l1
  220. 0x0d: Bishop 1 f3 r3
  221. 0x0e: Rook 2 r3
  222. 0x0f: Knight 1 b1 l2
  223. 0x12: Bishop 1 f7 r7
  224. 0x13: King f1
  225. 0x14: Pawn 8 f1 r1
  226. 0x15: Bishop 1 f5 r5
  227. 0x18: Pawn 7 f1
  228. 0x1a: Queen 2 f6
  229. 0x1b: Bishop 1 f1 l1
  230. 0x1d: Bishop 2 f7 r7
  231. 0x21: Rook 2 r7
  232. 0x22: Bishop 2 f2 l2
  233. 0x23: Queen 2 f6 r6
  234. 0x24: Pawn 8 f1 l1
  235. 0x26: Bishop 1 f7 l7
  236. 0x27: Pawn 3 f1 l1
  237. 0x28: Queen 1 f5 r5
  238. 0x29: Queen 1 r6
  239. 0x2a: Knight 2 b2 r1
  240. 0x2d: Pawn 6 f1 r1
  241. 0x2e: Bishop 1 f1 r1
  242. 0x2f: Queen 1 r1
  243. 0x30: Knight 2 b2 l1
  244. 0x31: Queen 1 r3
  245. 0x32: Bishop 2 f5 r5
  246. 0x34: Knight 1 f2 r1
  247. 0x36: Knight 1 f1 r2
  248. 0x37: Queen 1 f4
  249. 0x38: Queen 2 f4 l4
  250. 0x39: Queen 1 r5
  251. 0x3a: Bishop 1 f6 r6
  252. 0x3b: Queen 2 f5 l5
  253. 0x3c: Bishop 1 f5 l5
  254. 0x41: Queen 2 f5 r5
  255. 0x42: Queen 1 f7 l7
  256. 0x44: King b1 r1
  257. 0x45: Queen 1 f3 r3
  258. 0x4a: Pawn 8 f2
  259. 0x4b: Queen 1 f5 l5
  260. 0x4c: Knight 2 f2 r1
  261. 0x4d: Queen 2 f1
  262. 0x50: Rook 1 f6
  263. 0x52: Rook 1 r6
  264. 0x54: Bishop 2 f1 l1
  265. 0x55: Pawn 3 f1
  266. 0x5c: Pawn 7 f1 r1
  267. 0x5f: Pawn 5 f2
  268. 0x61: Queen 1 f6 r6
  269. 0x62: Pawn 2 f2
  270. 0x63: Queen 2 f7 l7
  271. 0x66: Bishop 1 f3 l3
  272. 0x67: King f1 r1
  273. 0x69: Rook 2 f7
  274. 0x6a: Bishop 1 f4 r4
  275. 0x6b: O-O
  276. 0x6e: Rook 1 r5
  277. 0x6f: Queen 2 f7 r7
  278. 0x72: Bishop 2 f7 l7
  279. 0x74: Queen 1 r2
  280. 0x79: Bishop 2 f6 l6
  281. 0x7a: Rook 1 f3
  282. 0x7b: Rook 2 f6
  283. 0x7c: Pawn 3 f1 r1
  284. 0x7d: Rook 2 f1
  285. 0x7e: Queen 1 f3 l3
  286. 0x7f: Rook 1 r1
  287. 0x80: Queen 1 f6 l6
  288. 0x81: Rook 1 f1
  289. 0x82: Pawn 6 f1 l1
  290. 0x85: Knight 1 f2 l1
  291. 0x86: Rook 1 r7
  292. 0x87: Rook 1 f5
  293. 0x8a: Knight 1 b2 r1
  294. 0x8b: Pawn 1 f1 r1
  295. 0x8c: King b1 l1
  296. 0x8e: Queen 2 f2 l2
  297. 0x8f: Queen 1 r7
  298. 0x92: Queen 2 f1 r1
  299. 0x94: Queen 1 f3
  300. 0x96: Pawn 2 f1 r1
  301. 0x97: King l1
  302. 0x98: Rook 1 r3
  303. 0x99: Rook 1 f4
  304. 0x9a: Queen 1 f6
  305. 0x9b: Pawn 3 f2
  306. 0x9d: Queen 1 f2
  307. 0x9f: Bishop 2 f4 l4
  308. 0xa0: Queen 2 f3
  309. 0xa2: Queen 1 f2 r2
  310. 0xa3: Pawn 8 f1
  311. 0xa5: Rook 2 f5
  312. 0xa9: Rook 2 r2
  313. 0xab: Queen 2 f6 l6
  314. 0xad: Rook 2 r4
  315. 0xae: Queen 2 f3 r3
  316. 0xb0: Queen 2 f4
  317. 0xb1: Pawn 6 f2
  318. 0xb2: Bishop 1 f6 l6
  319. 0xb5: Rook 2 r5
  320. 0xb7: Queen 1 f5
  321. 0xb9: Bishop 2 f3 r3
  322. 0xbb: Pawn 5 f1
  323. 0xbc: Queen 2 r5
  324. 0xbd: Queen 2 f2
  325. 0xbe: King r1
  326. 0xc1: Bishop 1 f2 r2
  327. 0xc2: Bishop 2 f2 r2
  328. 0xc3: Bishop 1 f2 l2
  329. 0xc4: Rook 2 r1
  330. 0xc5: Rook 2 f4
  331. 0xc6: Queen 2 f5
  332. 0xc7: Pawn 7 f1 l1
  333. 0xc8: Pawn 7 f2
  334. 0xc9: Queen 2 f7
  335. 0xca: Bishop 2 f3 l3
  336. 0xcb: Pawn 6 f1
  337. 0xcc Bishop 2 f5 l5
  338. 0xcd: Rook 1 r2
  339. 0xcf: Pawn 4 f1
  340. 0xd1: Pawn 2 f1 l1
  341. 0xd2: Knight 2 f1 r2
  342. 0xd3: Knight 2 f1 l2
  343. 0xd7: Queen 1 f1 l1
  344. 0xd8: Rook 2 r6
  345. 0xd9: Queen 1 f2 l2
  346. 0xda: Knight 1 b2 l1
  347. 0xdb: Pawn 1 f2
  348. 0xde: Pawn 5 f1 l1
  349. 0xdf: King f1 l1
  350. 0xe0: Knight 2 b1 r2
  351. 0xe1: Rook 1 f7
  352. 0xe3: Rook 2 f3
  353. 0xe5: Queen 1 r4
  354. 0xe6: Pawn 4 f2
  355. 0xe7: Queen 1 f4 r4
  356. 0xe8: Rook 1 f2
  357. 0xe9: Knight 1 b1 r2
  358. 0xeb: Pawn 4 f1 r1
  359. 0xec: Pawn 1 f1
  360. 0xed: Queen 1 f7 r7
  361. 0xee: Queen 2 f1 l1
  362. 0xef: Rook 1 r4
  363. 0xf0: Queen 2 r7
  364. 0xf1: Queen 1 f1 r1
  365. 0xf3: Knight 2 f2 l1
  366. 0xf4: Rook 2 f2
  367. 0xf5: Bishop 2 f1 r1
  368. 0xf6: O-O-O
  369. 0xf7: Knight 1 f1 l2
  370. 0xf8: Queen 2 r1
  371. 0xf9: Queen 2 f6
  372. 0xfa: Queen 2 r3
  373. 0xfb: Queen 2 f2 r2
  374. 0xfd: Queen 1 f7
  375. 0xfe: Queen 2 f3 l3
  376.  
  377. After the byte describing the move, the annotation for that move is stored as
  378. a single byte:
  379.  
  380. 0x00: No annotation
  381. 0x01: !
  382. 0x02: ?
  383. 0x03: !!
  384. 0x04: ??
  385. 0x05: !?
  386. 0x06: ?!
  387. 0x08: Only move
  388. 0x16: Zugzwang
  389.  
  390. Note that the other annotations (=, Unclear, =+, etc.) belong to the position
  391. and not the move, as described in section 1.4.13.
  392.  
  393. 1.4.9. Position statistics
  394.  
  395. After all moves and annotations have been encoded, the statistics for this
  396. position are stored:
  397.  
  398. - First, a three-byte integer describing the number of games for this
  399. position. This is the number reported in parenthesises after "N = 12345"
  400. in Chessbase. (The "real" N number is the sum of the number of wins,
  401. draws and losses.)
  402. - Then, three bytes describing the number of wins for white (1-0). Remember
  403. that the position is always stored from white's perspective, so if black
  404. is to move, one will need to swap the numbers for 1-0 and 0-1.
  405. - Then, three bytes describing the number of wins for black (0-1).
  406. - Then, three bytes describing the number of draws (1/2).
  407.  
  408. The percentages and performance percentages are calculated from these
  409. numbers, seemingly with correct rounding.
  410.  
  411. 1.4.10. Unknown integer
  412.  
  413. After the statistics, an unknown 4-byte integer is stored. It is almost
  414. always zero, but sometimes another small number (typically in the single
  415. digits).
  416.  
  417. 1.4.11. Ratings
  418.  
  419. After the unknown integer, rating information for this position is stored.
  420. There are two ratings. Both are stored first as a number of games (this is
  421. the number shown after the "-" to the lower right in Chessbase) in three
  422. bytes, and then the sum of the ratings in four bytes. To get the average
  423. rating (the number shown before the "-"), divide the second number by the
  424. first number (guarding for division by zero).
  425.  
  426. The performance rating is calculated from these ratings and the position
  427. statistics.
  428.  
  429. 1.4.12. Engine recommendations
  430.  
  431. After the ratings, a single byte is stored for the position's
  432. recommendations. The possibilities are:
  433.  
  434. 0x00: No special preference
  435. 0x40: Don't play in tournaments (red in the GUI)
  436. 0x80: Main move (green in the GUI)
  437.  
  438. Other values have been spotted (0x04, 0a10, 0x14, 0x20, 0x60, 0xa0), without
  439. knowing exactly what they are. It may be that this is actually a bit field.
  440.  
  441. Again, note that this value belongs to the position entry, not the move, so
  442. when checking a move's desirability, one will need to look up the resulting
  443. position and check this byte.
  444.  
  445. After the engine recommendation, a second unknown byte is stored. This may be
  446. a weight somehow, or it may be something else.
  447.  
  448. 1.4.13. Position commentary
  449.  
  450. Finally for the position, the commentary is stored as a single byte. The
  451. following values are legal:
  452.  
  453. 0x00: None
  454. 0x0b: =
  455. 0x0d: Unclear
  456. 0x0e: =+
  457. 0x0f: +=
  458. 0x10: -/+
  459. 0x11: +/-
  460. 0x13: +-
  461. 0x20: Development adv.
  462. 0x24: Initiative
  463. 0x28: With attack
  464. 0x2c: Compensation
  465. 0x84: Counterplay
  466. 0x8a: Zeitnot
  467. 0x92: Novelty
  468.  
  469. 2. The CTB file
  470.  
  471. Unknown, except that it may be a bit field of some sort over the pages in the
  472. CTG file. However, two values are of special interest:
  473.  
  474. - The lower storage bound, a 4-byte integer stored at offset 4.
  475. - The upper storage bound, a 4-byte integer stored at offset 8.
  476.  
  477. The usage of these bounds will be clear from section 3.
  478.  
  479. 3. The CTO file
  480.  
  481. Note that the CTO file is not as well understood as the CTG file. As such,
  482. the information presented here is mainly guesswork, and may be wrong.
  483.  
  484. The CTO file is an index into the CTG file, for rapid lookup. It is believed
  485. to be a simple hash table, with no forms of overflow, so only a single lookup
  486. in the CTO file is required to find the right page in the CTG file for a
  487. given position. (It is guessed that if a given page in the CTG file becomes
  488. too big, the number of pages is increased and all the positions moved
  489. around.)
  490.  
  491. The CTO file starts with sixteen header bytes. At file offset 4, a 4-byte
  492. integer is stored, describing the number of entries in the CTO file. (This
  493. seems to neither be a prime nor a power of two.)
  494.  
  495. After the header, four bytes are stored for each entry. When looking up a
  496. position, the position is hashed, and the hash value is reduced relative to
  497. the number of index entries. The appropriate four-byte value in the CTO file
  498. is then looked up based on the hash. The number is a page number in the
  499. CTG file, which is then read and searched for the position. (If the page in
  500. the CTG file does not actually contain the position, the GUI seems to simply
  501. fail the lookup, so there appears to be no provision for traditional
  502. overflowing.) -1 (ff ff ff ff) means that no positions with this (reduced)
  503. hash value exists. More than one hash value may point to the same page in the
  504. CTG file.
  505.  
  506. The code for computing a 32-bit hash from a position (which is encoded
  507. exactly as in the CTG file, including the header byte) is the equivalent
  508. of this C code:
  509.  
  510. unsigned int tbl[] = {
  511. 0x3100d2bf, 0x3118e3de, 0x34ab1372, 0x2807a847,
  512. 0x1633f566, 0x2143b359, 0x26d56488, 0x3b9e6f59,
  513. 0x37755656, 0x3089ca7b, 0x18e92d85, 0x0cd0e9d8,
  514. 0x1a9e3b54, 0x3eaa902f, 0x0d9bfaae, 0x2f32b45b,
  515. 0x31ed6102, 0x3d3c8398, 0x146660e3, 0x0f8d4b76,
  516. 0x02c77a5f, 0x146c8799, 0x1c47f51f, 0x249f8f36,
  517. 0x24772043, 0x1fbc1e4d, 0x1e86b3fa, 0x37df36a6,
  518. 0x16ed30e4, 0x02c3148e, 0x216e5929, 0x0636b34e,
  519. 0x317f9f56, 0x15f09d70, 0x131026fb, 0x38c784b1,
  520. 0x29ac3305, 0x2b485dc5, 0x3c049ddc, 0x35a9fbcd,
  521. 0x31d5373b, 0x2b246799, 0x0a2923d3, 0x08a96e9d,
  522. 0x30031a9f, 0x08f525b5, 0x33611c06, 0x2409db98,
  523. 0x0ca4feb2, 0x1000b71e, 0x30566e32, 0x39447d31,
  524. 0x194e3752, 0x08233a95, 0x0f38fe36, 0x29c7cd57,
  525. 0x0f7b3a39, 0x328e8a16, 0x1e7d1388, 0x0fba78f5,
  526. 0x274c7e7c, 0x1e8be65c, 0x2fa0b0bb, 0x1eb6c371
  527. };
  528.  
  529. unsigned int gen_hash(signed char *ptr, unsigned len)
  530. {
  531. signed hash = 0;
  532. short tmp = 0;
  533. int i;
  534.  
  535. for (i = 0; i < len; ++i) {
  536. signed char ch = *ptr++;
  537. tmp += ((0x0f - (ch & 0x0f)) << 2) + 1;
  538. hash += tbl[tmp & 0x3f];
  539. tmp += ((0xf0 - (ch & 0xf0)) >> 2) + 1;
  540. hash += tbl[tmp & 0x3f];
  541. }
  542. return hash;
  543. }
  544.  
  545. Note that this code may not be 64-bit clean, as it relies on 32-bit overflow
  546. behavior of the addition to the hash variable.
  547.  
  548. The reduction of this 32-bit hash to a value in the CTO file is not
  549. completely known. The following C code is believed to approximate the
  550. lookup, and is worst-case O(log n) (usually much better) in the number of
  551. index entries:
  552.  
  553. for (int n = 0; n < 0x7fffffff; n = 2*n + 1) {
  554. unsigned c = (hash & n) + n;
  555.  
  556. if (c < lower_bound)
  557. continue;
  558.  
  559. search_page(c);
  560.  
  561. if (c >= upper_bound)
  562. break;
  563. }
  564.  
  565. Here, lower_bound and upper_bound are the values found in the CTB file as
  566. described in section 2. search_page() indicates that the given value should
  567. be looked up in the CTO file, and the resulting page in the CTG file (if
  568. any) should be searched for the given position. ChessBase itself seems to
  569. have more conditional logic around search_page(), but unless you want
  570. to make new CTG files yourself this uncertainity should not be a big
  571. problem.
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment