|
@ -910,46 +910,3 @@ Chess.Position.prototype.unmakeMove = function() { |
|
|
|
|
|
|
|
|
return move; |
|
|
return move; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
function test() { |
|
|
|
|
|
var cache = new Array(1000000); |
|
|
|
|
|
var collisions = 0; |
|
|
|
|
|
var hits = 0; |
|
|
|
|
|
|
|
|
|
|
|
function perft(depth, chessPosition) { |
|
|
|
|
|
if (!depth) { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var zobrist = chessPosition.hashKey; |
|
|
|
|
|
var hashKey = zobrist.getHashKey(); |
|
|
|
|
|
|
|
|
|
|
|
if (cache[hashKey % cache.length]) { |
|
|
|
|
|
if (cache[hashKey % cache.length].zobrist.isEqual(zobrist)) { |
|
|
|
|
|
++hits; |
|
|
|
|
|
return cache[hashKey % cache.length].nodes; |
|
|
|
|
|
} |
|
|
|
|
|
++collisions; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var nodes = 0; |
|
|
|
|
|
|
|
|
|
|
|
chessPosition.getMoves(true).forEach(function(move) { |
|
|
|
|
|
if (chessPosition.makeMove(move)) { |
|
|
|
|
|
nodes += perft(depth - 1, chessPosition); |
|
|
|
|
|
chessPosition.unmakeMove(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
cache[hashKey % cache.length] = { zobrist: zobrist.dup(), nodes: nodes }; |
|
|
|
|
|
|
|
|
|
|
|
return nodes; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
window.console.log("Perft: " + perft(4, new Chess.Position)); |
|
|
|
|
|
window.console.log("Hits: " + hits + ", collisions: " + collisions); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
test(); |
|
|
|
|
|
*/ |
|
|
|
|
|