Zobrist Hash算法的基础:按位异或运算的性质
来源:互联网 发布:北航人工智能研究生 编辑:程序博客网 时间:2024/06/06 03:25
用途
Zobrist Hash算法是各类棋类程序中判断历史局面是否存在的算法。
算法基础
该算法的的基础利用了按位异或运算的如下性质:A^B^B = A
C++代码示例
// mersenne_twister_engine constructor #include <iostream> #include <chrono> #include <random> #include <list>using namespace std;int main(){// obtain a seed from the system clock: unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();// obtain a seed from the user: std::mt19937 g1(seed1); // mt19937 is a standard mersenne_twister_engine std::cout << "A time seed produced: " << g1() << std::endl;std::cout << typeid(g1()).name() << " sizeof(" << typeid(g1()).name() << ") = " << sizeof(g1()) << endl;list<unsigned> listInt;int current = 0;cout << "current=" << current << endl;for (int i = 0; i < 10; ++i){int temp = g1();current ^= temp;listInt.push_back(temp);cout << "temp=" << temp << " current=" << current << endl;}cout << endl;for (auto itr = listInt.crbegin(); itr != listInt.crend(); ++itr){int temp = *itr;cout << "temp=" << temp << " current=" << current << endl;current ^= temp;}cout << "current=" << current << endl;return 0;}
运行结果
阅读全文
0 0
- Zobrist Hash算法的基础:按位异或运算的性质
- 异或运算的性质
- 异或运算的性质
- [转]异或的性质和运算
- 异或的性质和运算
- 异或的性质和运算
- 异或的性质和运算
- 异或运算的性质及用途
- 异或的性质和运算
- 异或算法的性质和使用
- 异或的性质和运算(转)
- Positive Xor 位运算, 异或的性质
- 位运算的性质
- 位运算的性质
- 位运算的性质
- 异或的性质
- HDU4801DP,异或运算,与运算,hash的应用
- 算法的性质
- TensorFlow基础 介绍
- 使用RestFulWebService根据人员登录名获取人员信息
- java 复杂链表的复制
- 网络游戏NetPacket包与sendBuffer
- SQL Server
- Zobrist Hash算法的基础:按位异或运算的性质
- C++ 数组长度不能为0
- 算法 分金币
- ArrayList
- 关于微信红包简单算法 PHP Edition
- post和get的区别
- 基于AJAX的文件上传显示进度条实现
- 计算机视觉与摄影测量的不同
- Matlab图像处理中im2double和double的区别