hash - Minimax algorithm with memoization? -


i trying implement connect 4 ai using minimax algorithm in javascript. currently, slow. other alpha beta pruning implement, wondering if worth hash gamestates 1) heuristic evaluations , 2) next best move. can see why 2 useful since there many ways same game state wondering if have hash current depth make work. example, if reached state depth of 3 (so 4 more moves ahead) vs depth of 2 5 moves ahead, might arrive @ different answer. doesn't mean should take depth account hash? second question whether hashing boards evaluations worth it. takes me o(n) time build hash, , o(n) time evaluate board (though more o(2 or 3n)). gamestates hashed evaluations, or overkill?

whenever hash value of state (using heuristics), need have information depth @ state evaluated. because there big difference between the value 0.1 @ depth 1 , the value 0.1 @ depth 20. in first case barely investigated space, pretty unsure happens. in second case have done huge amount of work, kind of know talking about.

the thing games not know depth position. example chess. in connect 4, looking @ position know depth.

enter image description here enter image description here

for connect 4 depth here 14 (only 14 circles have been put). not need store depth.

as whether have hash state or re-evaluate it. position in game can reached through many game-paths, kind of expect hash helpful. important question trade-off of creating/looking @ hash , how intensive evaluation function is. if looks lot of work - hash , benchmark.

one last suggestion. mentioned alpha-beta more helpful hashing @ stage (and not hard implement). can go further , implement move ordering alpha-beta. if you, it, , after implement hashing.