Prob_Solve 板


LINE

針對 Zobrist Hashing 回您: ///////////////////// // define puzzle size #define N 3 ////////////////////// // Zobrist Hash Table: // // // 維度一: 數字(ex: N = 3,數字為 1 ~ 9 // N = 4,數字為 1 ~ 16) // // 維度二: 座標(由左至右;由上至下) (ex: N = 3,座標為 0 1 2 3 4 5 6 7 8) UINT64 ZobristTable[N * N + 1][N * N]; //////////////////////////////// // 產生 unsigned int 64 隨機亂數 UINT64 rand64(void){ return rand() ^ ((UINT64)rand() << 15) ^ ((UINT64)rand() << 30) ^ ((UINT64)rand() << 45) ^ ((UINT64)rand() << 60) ; } //////////////////// // 初始化 Hash Table void InitializeZobristTable(){ int i; int j; for(i = 1; i <= N * N; ++i){ for(j = 0; j < N * N; ++j){ ZobristTable[i][j] = rand64(); } } } 做好上面的準備功夫以後 以 N = 3初始盤面假設為 3 1 2 5 4 6 7 8 則 Hash Key 取得方法為 UINT64 ZobristKey; ZobristKey ^= ZobristTable[3][0]; ZobristKey ^= ZobristTable[1][1]; ZobristKey ^= ZobristTable[2][2]; ZobristKey ^= ZobristTable[5][3]; ZobristKey ^= ZobristTable[4][4]; ZobristKey ^= ZobristTable[6][5]; ZobristKey ^= ZobristTable[7][6]; ZobristKey ^= ZobristTable[8][7]; 如果今天 6 往下移動 3 1 2 5 4 7 8 6 新 Hash Key 則為 ZobristKey ^= ZobristKeyTable[6][5]; ZobristKey ^= ZobristKeyTable[6][8]; 解說完畢 :) ※ 引述《soheadsome (師大狗鼻哥)》之銘言: : 這次也是半作業文 : 人工智慧的作業 : 這次是要用local beam search來解puzzle的問題 : 3<= n <= 7 : 但我現在卡在我不知道puzzle盤面的hash要怎麼做 : 講義也沒寫 : 我有找到一個棋盤的hash algorithm : http://goo.gl/1fwGcG : 我不知道要怎麼使用到puzzle的問題上 : 麻煩前輩們指點<(_ _)> 謝謝 --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.61.233.210
※ 文章網址: http://webptt.com/m.aspx?n=bbs/Prob_Solve/M.1398649934.A.9C0.html
1F:推 soheadsome:十分感謝!!!! 我晚點再來仔細看 04/28 12:27
2F:推 soheadsome:那如果n大約4 會衝突嗎? 04/28 15:25
3F:推 LPH66:你的衝突是指? hash collision? 04/29 07:12
4F:→ LPH66:n 即使到 7 所用到的亂數個數也只有 7^4 = 2401 個 04/29 07:13
5F:→ LPH66:跟 64 bit 的組合比起來依然是不怎麼可能的 04/29 07:14
6F:→ LPH66:再說 Zobrist hash 的目的本來就不是在要求 perfect hash 04/29 07:14
7F:→ LPH66:萬一出事了也只不過是多搜幾種而已 04/29 07:15
※ 編輯: cutekid (61.221.80.36), 04/29/2014 09:49:45







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BuyTogether站內搜尋

TOP