| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2294 人关注过本帖, 1 人收藏
标题:求解:90个数字哈希表与神秘数字
取消只看楼主 加入收藏
G笨鸟先飞
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2019-9-23
收藏(1)
 问题点数:0 回复次数:3 
求解:90个数字哈希表与神秘数字
求解:90个数字哈希表与神秘数字
unsinged int v;  // 整数
int r;           // 运算结果
static const int MultiplyDeBruijnBitPosition[32] ={
  0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
  31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
r = MultiplyDeBruijnBitPosition[((uint32_t)((v & -v) * 0x077CB531U)) >> 27];

 

64位的如下: 神秘数字:0x3f79d71b4cb0a89UL
64个数字的哈希表为:
const char g_math_64[] ={0,1,48,2,57,49,28,3,61,58,50,42,38,29,17,4,62,55,59,36,53,51,
43,22,45,39,33,30,24,18,12,5,63,47,56,27,60,41,37,16,54,35,52,21,44,32,23,11,46,26,40,
15,34,20,31,10,25,14,19,9,13,8,7,6};
求log2的算法:
#define LOG2_64(v) g_math_64[(uint64_t)((v& -v) * 0x3f79d71b4cb0a89UL) >> 58]

 
如何写出90个数字的哈希表?
90位数字的神秘数字是多少?



请指教!谢了


[此贴子已经被作者于2019-9-24 19:22编辑过]

搜索更多相关主题的帖子: int 数字 const define 哈希表 
2019-09-24 18:23
G笨鸟先飞
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2019-9-23
收藏
得分:0 
谢谢二位版主的回复!
为什么菜鸟我想发这贴子?因为不懂。。。。。。

以下是国际象棋引擎作者自己介绍他写的引擎情况:
# Ethereal

Ethereal is a UCI-compliant chess engine. It uses the traditional alpha-beta framework in addition to a variety of pruning, reduction, extension, and other improvements. Some of those improvements include Static Null Move Pruning, Null Move Pruning, Node Razoring, Depth base Futility Pruning, Best-Case Delta Pruning, Current-Move Delta Pruning, Late Move Reductions, Check extensions, and the use of various Transposition Tables. Ethereal generates moves using the Fancy Magic BitBoard technique, but also uses a redundant 64-length array to store pieces for easier lookup. Ethereal is an original engine aside from the Piece Square Tables (currently using Toga II's tables). It is greatly influenced from Crafty, Stockfish, TSCP, MadChess, and Fruit. Ethereal is a hobby project, but more importantly it is an active resume.

# Elo Progression ( Ethereal7.33 and onward )

| Version |  Elo |
| ------: | ---: |
| v7.33   |  2154|
| v7.40   |  2172|
| v7.42   |  2189|
| v7.49   |  2196|
| v7.55   |  2210|
| v7.57   |  2247|
| v7.58   |  2275|
| v7.60   |  2453|
| v7.61   |  2482|
| v7.65*  |  2503|
| v7.69   |  2532|
| v7.70   |  2549|

# Development

As of now, I am the sole contributor to the project. However, I will happily review any Pull Requests and consider merging them into the project. The License on this project allows any individual to use, modify, and release my code and any derivatives made using my code. For any questions or comments, feel free to contact me at <Andrew@Grantnet.us>


作者编写的引擎用新的位棋盘技术很值得学习。我想将其引用到中国象棋引擎中。。。。。。
以下是作者引擎中一段代码
#include <stdint.h>
#include <assert.h>

#include "bitboards.h"
#include "bitutils.h"


int LsbLookupTable[64] = {
    0, 47, 1, 56, 48, 27,  2, 60,
   57, 49, 41, 37, 28, 16,  3, 61,
   54, 58, 35, 52, 50, 42, 21, 44,
   38, 32, 29, 23, 17, 11,  4, 62,
   46, 55, 26, 59, 40, 36, 15, 53,
   34, 51, 20, 43, 31, 22, 10, 45,
   25, 39, 14, 33, 19, 30,  9, 24,
   13, 18,  8, 12,  7,  6,  5, 63
};
  
/**
 * Count the number of set bits in a given 64-bit Integer
 *
 * @param   bb  BitBoard to count set bits in
 * @return      Count of all set bits in bb
 *计算设置位的数量在一个给定的64位整数
  *
  * @param bb位棋盘数套位
  * @return计数设置位的bb

 */
int countSetBits(uint64_t bb){
    int count = 0;
   
    while(bb){
        bb ^= (1ull << getLSB(bb));
        count += 1;
    }
   
    return count;
}

/**
 * Fill an array with the bit indexes of all set bits
 * in a given 64-bit Integer. Set the array index after
 * the last bit index location to -1 to indicate that
 * all bit indexes have been traversed
 *
 * @param   bb  BitBoard to get set bits in
 * @param   arr Integer Array to fill with bit indexes
 填充数组索引的所有部分
  *在给定的64位整数。设置后的数组索引
  *最后一点索引位置1,表示
  *已经遍历所有点索引
  *
  * @param bb位棋盘中位
  * @param arr整数数组填充索引
unsigned long 如何uint64_t
 
 
 */
void getSetBits(uint64_t bb, int * arr){
    int count = 0;
   
    while(bb){
        int lsb = getLSB(bb);//#define getLSB(bb) (LsbLookupTable[(((bb) ^ ((bb)-1)) * 0x03f79d71b4cb0a89ull) >> 58])
        arr[count] = lsb;//                              
        count += 1;
        bb ^= 1ull << lsb;
    }
   
   
    arr[count] = -1;
}


再次感谢二位版主的回复!

2019-09-25 15:23
G笨鸟先飞
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2019-9-23
收藏
得分:0 
国际象棋棋盘上有64个交叉点。中国象棋棋盘上有90个交叉点。如果90个数字哈希表与神秘数字找到了,该是什么个样子?
2019-09-25 15:29
G笨鸟先飞
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2019-9-23
收藏
得分:0 
https://www.
这个里面讲解的好详细。终于找到了这个…
再次谢谢大家…
以后不懂还会来的…
2019-09-26 09:23
快速回复:求解:90个数字哈希表与神秘数字
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025106 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved