See http://en.wikipedia.org/wiki/Zobrist_hashing Note: This is for Go only.
;Requires SRFI 27 and SRFI 60 (define last-hash '()) (define limit 79228162514264337593543950336) ;;Maximum 96 bit number for collision resistance. (define white-rep (random-integer limit)) (define black-rep (random-integer limit)) (define ko-rep (random-integer limit)) (define empty-rep (random-integer limit)) (define (zobrist-hash go-position-table) (let ((create-zobrist-hash (iterate-zobrist-hash white-rep black-rep ko-rep empty-rep go-position-table))) (if (number? last-hash) (begin (set! last-hash (bitwise-xor last-hash create-zobrist-hash)) (display last-hash)) (begin (set! last-hash create-zobrist-hash) create-zobrist-hash)))) (define (iterate-zobrist-hash white black ko open go-position-table) (apply bitwise-xor (letrec ((iter (lambda (go-position-table) (cond ((null? go-position-table) '()) ((number? (car go-position-table)) (cond ((eq? (car go-position-table) 0) (cons open (iter (cdr go-position-table)))) ((eq? (car go-position-table) 1) (cons white (iter (cdr go-position-table)))) ((eq? (car go-position-table) 2) (cons black (iter (cdr go-position-table)))) ((eq? (car go-position-table) 3) (cons ko (iter (cdr go-position-table)))))))))) (iter go-position-table))))