{
    "componentChunkName": "component---src-templates-note-note-js",
    "path": "/notes/position-hash",
    "result": {"data":{"mdx":{"body":"var _excluded = [\"components\"];\nfunction _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n/* @jsxRuntime classic */\n/* @jsx mdx */\n\nvar _frontmatter = {};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n    props = _objectWithoutProperties(_ref, _excluded);\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"chess is not \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/notes/path-dependent\",\n    \"title\": \"path dependent\"\n  }, \"path dependent\"), \" hence we can have positional hashes\"), mdx(\"p\", null, \"In chess, positional hashes are used to uniquely identify the state of a chess position. This is particularly useful in computer chess engines for tasks like \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/notes/detecting-repetitions\",\n    \"title\": \"detecting repetitions\"\n  }, \"detecting repetitions\"), \", \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/notes/evaluating-positions\",\n    \"title\": \"evaluating positions\"\n  }, \"evaluating positions\"), \", and optimizing \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"/notes/search-algorithms\",\n    \"title\": \"search algorithms\"\n  }, \"search algorithms\"), \". The most common method for creating positional hashes is called \", mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"\", mdx(\"a\", {\n    parentName: \"strong\",\n    \"href\": \"/notes/Zobrist-hashing\",\n    \"title\": \"Zobrist hashing\"\n  }, \"Zobrist hashing\"), \"\"), \".\"), mdx(\"h3\", null, \"Zobrist Hashing\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Initialization:\"), \" \"), mdx(\"ul\", {\n    parentName: \"li\"\n  }, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"A random number is assigned to each possible piece on each square of the chessboard. This includes all pieces (king, queen, rook, bishop, knight, pawn) for both colors (white and black) on all 64 squares.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Additional random numbers are assigned for castling rights, en passant squares, and the side to move.\"))), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Hash Calculation:\")), mdx(\"ul\", {\n    parentName: \"li\"\n  }, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"The hash for a given position is calculated by XORing the random numbers corresponding to the pieces on the board, the current castling rights, en passant square, and the side to move.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"This results in a unique hash value for each distinct position.\"))), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Efficiency:\")), mdx(\"ul\", {\n    parentName: \"li\"\n  }, mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Zobrist hashing is efficient because it allows for incremental updates. When a move is made, only the \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/notes/affected-pieces\",\n    \"title\": \"affected pieces\"\n  }, \"affected pieces\"), \" and board attributes need to be XORed to update the hash, rather than \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/notes/recalculating-it-from-scratch\",\n    \"title\": \"recalculating it from scratch\"\n  }, \"recalculating it from scratch\"), \".\"))), mdx(\"li\", {\n    parentName: \"ol\"\n  }, mdx(\"p\", {\n    parentName: \"li\"\n  }, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Applications:\")), mdx(\"ul\", {\n    parentName: \"li\"\n  }, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Repetition Detection:\"), \" By storing hash values, engines can quickly detect \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/notes/threefold-repetitions\",\n    \"title\": \"threefold repetitions\"\n  }, \"threefold repetitions\"), \".\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Transposition Tables:\"), \" Hashes are used to store and retrieve previously evaluated positions, improving search efficiency.\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"strong\", {\n    parentName: \"li\"\n  }, \"Move Ordering:\"), \" Helps in optimizing the order of moves to be evaluated.\")))), mdx(\"p\", null, \"Overall, positional hashes are a crucial component in the performance and accuracy of modern chess engines.\"), mdx(\"h2\", null, \"Extension\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Extending \", mdx(\"a\", {\n    parentName: \"li\",\n    \"href\": \"/notes/Zobrist-hashing\",\n    \"title\": \"Zobrist hashing\"\n  }, \"Zobrist hashing\"), \" from uniqueness in a game to uniqueness on a board across the games?\")));\n}\n;\nMDXContent.isMDXComponent = true;","inboundReferences":[]}},"pageContext":{"slug":"position-hash","node":{"childMdx":{"slug":"position-hash"}}}},
    "staticQueryHashes": []}