Different optimizations can be performed, especially on the detection of playable hits and the reusing of code snippet already implemented which has the same structure but for other functionalities. Given the native limitation of Javascript about the computing of "hits tree" as a function of the depth (see below with NegaMax algorithm), a webworkers version has been developped but requires some additionnal validation tests : to follow...
In Human-Computer game, one has to code a strategy allowing to maximize victory, by computing the best current "computer hit". For this, we use "NegaMax" algorithm that consists to process, from the current state of board, the tree of all potential hits. Once this tree generated, the choice of "computer hit" corresponds to the maximum gain among all leaves (depthest nodes of tree). So we can conclude that more depth is high (ie more the number of potential hits is big), more the chosen hit will be relevant from an heuristic point of view.
ps : join like me the Cosmology@Home project whose aim is to refine the model that best describes our Universe