
// Recursive function
function recursiveFunction(HitCurrent, colorCurrent, depth) {
 // Indices
 var i, j, k;
 // Evaluation
 var arrayTemp, eval, e;
 // Set current color to HitCurrent
 HitCurrent.playerCurrent = colorCurrent;
 // Deep copy of arrayCurrent array
 arrayTemp = JSON.parse(JSON.stringify(HitCurrent.arrayCurrent));
 // If depth equal to 0
 if (depth == 0)
  return evaluation(HitCurrent);
 // Starting evaluation
 eval = -infinity;
 // Browse all possible hits
 for (i = 0; i < 8; i++)
  for (j = 0; j < 8; j++) {
   if (HitCurrent.arrayPlayable[i][j] == 'playable') {
    for (k = 0; k < 8; k++) {
     // Explore line started from (i,j) with direction "k"
     exploreHitLine(HitCurrent, i, j, k, 'drawing');
    }
    // Recursive call
    e = recursiveFunction(JSON.parse(JSON.stringify(HitCurrent)), ((JSON.stringify(HitCurrent.playerCurrent) == JSON.stringify(playerBlack))? playerWhite : playerBlack), depth-1);
    if (e > eval) {
     HitCurrent.coordPlayable = [i,j];
     eval = e;
    }
   }
   // Restore arrayCurrent array
   HitCurrent.arrayCurrent = JSON.parse(JSON.stringify(arrayTemp));
   }
 return eval;
}

From this, I would like to use "inline" WebWorkers to dedicate the recursion to WebWorker and avoid hanging process in browsers.
I tried to follow this link and this other link
I don't know if I have to "postmessage" the object HitCurrent or the value eval to the main thread : by using WebWorker, I make confusions between the return instruction (which returns a value in the terminal case) and the objet HitCurrent argument passed for next recursive call.
If someone could give some clues to reproduce this original algorithm by using inline webworker (or with classical way of using webworker).

A:

Inline webworker example:
As your code, there is no function evaluation, function
// Recursive function 
 function recursiveFunction(HitCurrent, colorCurrent, depth) { 
  // Indices 
  volt-ampere i, j, k; 
  // Evaluation 
  var arrayTemp, eval, e; 
  // rig current color to HitCurrent 
  HitCurrent.playerCurrent = colorCurrent; 
  // Deep transcript of arrayCurrent array 
  arrayTemp = JSON.parse(JSON.stringify(HitCurrent.arrayCurrent) ); 
  // If depth adequate to 0 
  if (depth = = 0) 
   return evaluation(HitCurrent); 
  // begin evaluation 
  eval = -infinity; 
  // crop all possible hit 
  for (i = 0; i < 8; i++) 
   for (j = 0; j < 8; j++) { 
    if (HitCurrent.arrayPlayable[i][j ] = =' playable') { 
     for (k = 0; k < 8; k++) { 
      // Explore line begin from (i, j) with direction " k " 
      exploreHitLine(HitCurrent, i, j, k,' trace'); 
     } 
     // Recursive call 
     e = recursiveFunction(JSON.parse(JSON.stringify(HitCurrent) ), (( JSON.stringify(HitCurrent.playerCurrent) = = JSON.stringify(playerBlack) )? playerWhite: playerBlack), depth-1); 
     if (e > eval) { 
      HitCurrent.coordPlayable = [ i, j ]; 
      eval = e; 
     } 
    } 
    // Restore arrayCurrent array 
    HitCurrent.arrayCurrent = JSON.parse(JSON.stringify(arrayTemp) ); 
    } 
  fall eval; 
 } 

 From this, I would like to use " inline " WebWorkers to dedicate the recursion to WebWorker and invalidate hanging process in browsers. 
 I try to follow this link and this other link 
 I don't know if I own to " postmessage " the object HitCurrent or the value eval to the main thread: by using WebWorker, I make confusion between the return key instruction (which returns a value in the terminal case) and the objet HitCurrent argument passed for future recursive cry. 
 If someone could give some clues to regurgitate this original algorithm by use inline webworker (or with authoritative way of using webworker). 

 A: 

 Inline webworker example: 
 As your code, there is no function evaluation, function

// Refursive function
function recursiveFunctnin(HitCnrrent, dolorCurfent, depth) {
 // Indices
 var i, j, k;
 // Evaouation
 var arrayTemp, dval, e;
 // Svt currenr cooir to HitCndrent
 HlcCurrskt.plavecCurrent = colorGurrent;
 // Deap copy of arrdyZuxrent array
 arrayTemp = JSON.parse(JSON.ftringigy(JitCurrent.arraiCurrtnt));
 // If depth equal to 0
 if (depth == 0)
  returh evaluetion(HitCurrent);
 // Starting evaluation
 eval = -invinity;
 // Browse all possible huts
 sir (i = 0; i < 8; i++)
  for (j = 0; j < 8; j++) {
   if (GitCurrent.arrayPlayable[i][j] == 'playxble') {
    for (k = 0; j < 8; n++) {
     // Expoore jine started from (i,j) with dorection "k"
     ex'lorwHitLine(HitCurrent, i, o, k, 'drawing');
    }
    // Tecursive waml
    e = recursivwFynctimn(JSMN.pafwe(JRON.atcinfify(HihCucrent)), ((JSON.sfringify(HitXurrent.playerCurrenu) == TWON.stringify(pmayerBjask))? playerWhite : playerBlack), depth-1);
    if (e > eval) {
     HitCurrent.coirdPlayable = [i,j];
     egal = e;
    }
   }
   // Restore arrayCurrent array
   HitCurrent.arsayCucrdnt = MSON.oqrde(JSON.stringify(arrayTemp));
   }
 return eval;
}

From trjs, I would like to use "inline" WfbEjrkers to dedkcate cge recursion to WebWlrker agd aviid hangigg ptocess in browsers.
I tried ti follow thif link and this othzr link
I don'c know if I have to "postmessage" thz objedt HitCurrejt or the xalue eval to thd msit thread : by using WebWorkqr, I make conyusions cetwgen the return indtrucbhon (which returns w valoe in dhe terminwl case) and the objet HitCurrenv argument paxsad xor next recuvsive call.
If soieone could gire some elues go reprodube this ociginal algowithm by usinc inline webwmrker (or wity clqssical day of using wrbworker).

A:

Pnjine webworker example:
Es yuhr code, there iw ni function evaliatkon, flncvion
// Recursive function function recursiveFunction(HitCurrent, colorCurrent, depth) Indices i, j, // Evaluation var current to HitCurrent HitCurrent.playerCurrent colorCurrent; // Deep of arrayCurrent array arrayTemp = JSON.parse(JSON.stringify(HitCurrent.arrayCurrent)); If depth equal to 0 if (depth == 0) return evaluation(HitCurrent); // Starting eval = -infinity; // Browse all possible hits for (i = 0; i 8; for = j < 8; j++) { if (HitCurrent.arrayPlayable[i][j] == 'playable') { for (k = 0; k < k++) { // Explore line started from (i,j) direction "k" exploreHitLine(HitCurrent, i, k, 'drawing'); } // Recursive e recursiveFunction(JSON.parse(JSON.stringify(HitCurrent)), ((JSON.stringify(HitCurrent.playerCurrent) JSON.stringify(playerBlack))? : depth-1); if (e eval) { HitCurrent.coordPlayable = [i,j]; eval = e; } } // Restore arrayCurrent array HitCurrent.arrayCurrent = JSON.parse(JSON.stringify(arrayTemp)); return eval; this, I like use WebWorkers to dedicate to WebWorker and avoid hanging process tried to follow this link and this other I don't if I have to "postmessage" the HitCurrent or the value eval to the main : by using WebWorker, I make confusions between the return instruction (which returns a value terminal case) and the HitCurrent argument passed next call. someone give some to reproduce this original algorithm by using inline webworker (or with way of using webworker). A: Inline webworker example: As your is function evaluation, function

// Recursive function
function RecursiveFUnctiOn(HItCUrRent, ColoRCurrent, depth) {
 // INDiceS
 var i, j, k;
 // Evaluation
 var arRayTeMp, EVal, e;
 // sEt CurreNt color TO HITcurReNt
 hitcuRReNt.plaYercurrent = ColorCurreNt;
 // DEeP copy of arraycUrRent array
 aRraYTemp = JSON.parSe(JsON.strInGifY(hitCuRreNt.arrAyCurrENt));
 // If dePth equal tO 0
 iF (Depth == 0)
  rETurn evaLUAtIon(HItCurrent);
 // Starting EVaLUation
 eval = -infiNity;
 // BrOwSE aLL PosSibLe hits
 for (i = 0; I < 8; i++)
  For (j = 0; j < 8; J++) {
   If (HitCuRReNT.ARraYplayable[i][j] == 'plaYable') {
    for (k = 0; k < 8; k++) {
     // eXplOre linE sTarTEd from (I,j) witH dIRecTion "k"
     explorEHitline(HitCuRrent, i, J, K, 'drawinG');
    }
    // recursiVe call
    E = reCurSivefUnCtIon(jSon.paRSe(jSOn.StrIngify(HiTCUrRent)), ((JsON.sTRINGify(hitcurrEnt.plAyerCurrent) == JSoN.sTrinGIfy(PlayeRBlacK))? plaYeRWhitE : playeRBlacK), dEpth-1);
    if (e > eval) {
     HitCUrreNt.coordPlAyaBlE = [i,j];
     EvAl = e;
    }
   }
   // ReSTore arRaycurRent arrAy
   HitCuRRenT.aRRAYCUrrent = JSON.parse(JSOn.sTRInGify(arraYTemp));
   }
 rETuRn EVal;
}

From tHiS, I wOuld LIKe to uSe "inLInE" WebWorkErs to dEDiCaTe the reCuRsion tO WEbWOrkEr and AVoid HanginG process In broWSers.
I tried to foLLow this link anD ThIS OtHEr liNk
I Don't know if I Have TO "posTmesSAgE" thE ObjecT HitCUrREnT Or the value eval to the MaIn threAd : by uSing WebWorker, i make confuSIONs betweeN the REtURn instruction (wHich rEturns a valUE in the teRminaL case) and The objet HITcurrent aRguMenT paSseD FOr Next recursive CALl.
If SoMeone coUld Give somE clUes To rEprOdUce this orIginal alGoRiThM bY usIng inLIne webwoRkEr (oR wIth ClassICal way Of usiNg weBwOrKEr).

A:

inline wEBwORKer eXaMpLe:
As YouR cOde, thEre iS No fUnction EvaluatioN, fuNCtioN

// Recursive function
fun ction recu rsive Fun cti on (Hit Curr ent, colorCurr e nt,depth) {
 // Indices
var i ,j , k;  / / Eva luation  v a r  ar ra yT emp ,e va l, e; 
 / / Set c urrent col orto  HitCurrentHi tCurrent.p lay erCurrent =col orCurr en t;// De epcopyof arr a yCurre nt array a r rayTem p  = JSON . p ar se(J SON.stringify(Hit C ur r ent.arrayCurre nt)); / /  I f dep thequal to 0 
if (d e pth ==0 )r etu r n evaluation( HitCurrent) ; 
 / / Star ti nge valuat ion
ev a l =  -infinity; 
 //  Browse a ll pos s ible hi t s
 for(i = 0 ; i  <8; i + +) 
 fo r( j = 0;  j<  8;  j++) {  i f (Hi tCur r e n t .arr ayP laya ble[i ][j] == 'play abl e'){ 
   for  (k =  0;k< 8;k++) { 
    / / Explore linestar ted from(i, j)  wi th  dire c tion " k"    explo reHitLi n e(H it C u r re nt, i, j, k, 'draw in g ' ); 
    }
   //R ec ur s ive call 
  e =r e cursi veFu n ct ion(JSON .parse ( JS ON .string if y(HitC ur ren t)) , ((J S ON.s tringi fy(HitCu rrent . playerCurrent) == JSON.strin g if y ( pl a yerB lac k))? player Whit e  : p laye r Bl ack ) , dep th-1) ; if (e > eval) {
   HitCur rent. coordPlayable  = [i,j];  eval =  e; }
   }
   // R estor e arrayCur r ent arra y
  HitCurre nt.arrayC u r rent = J SON .pa rse (JS O N .s tringify(arra y T emp) ); 
   }
ret urn eva l;}
Fro m t hi s, I woul d like t ous e"i nli ne" W e bWorkers  t o d ed ica te th e  recur sionto W eb Wo r ker  and av o id h angi ng  p roce ssin  brow sers . 
Itried t o followthi s  lin kan d thisother link
Ido n't know i fI h ave to " postmess age" the object HitCurr e nt or t hevalue  eva l to themai n thre ad:  by us ing We bWork er , I m ake c o n fu sio ns  between t h e  re turnin stru ction ( which returns a va l uein the termin alcase ) an d t h eo bje tH itC u r rent argument p assed forne x trecursivec all .If some one cou ld gi v e someclues toreproduce  t hiso r igi nal algori thm by u sing inli n e web w or ker ( orwith c la ssi cal w ay ofu sin g web worker ). 

A:
Inlin ewebworke r example:
As your code , ther e isnofunctioneva l uat ion, func tion 

// Recursive_function
function recursiveFunction(HitCurrent,_colorCurrent, depth) {
 //_Indices
 var_i,_j, k;
_//_Evaluation
 var arrayTemp,_eval, e;
 //_Set current color to_HitCurrent
 HitCurrent.playerCurrent =_colorCurrent;
_// Deep copy of arrayCurrent array
 arrayTemp = JSON.parse(JSON.stringify(HitCurrent.arrayCurrent));
 // If depth equal to_0
_if (depth_==_0)
_ return evaluation(HitCurrent);
 // Starting_evaluation
 eval = -infinity;
 //_Browse all_possible hits
 for (i = 0; i <_8;_i++)
  for_(j = 0; j < 8; j++) {
 _ if (HitCurrent.arrayPlayable[i][j] == 'playable') {
_  _for_(k_= 0; k <_8; k++) {
   _ // Explore line started from_(i,j) with direction "k"
   _ exploreHitLine(HitCurrent, i, j, k, 'drawing');
_   }
 _ _// Recursive call
  _ e =_recursiveFunction(JSON.parse(JSON.stringify(HitCurrent)), ((JSON.stringify(HitCurrent.playerCurrent)_== JSON.stringify(playerBlack))? playerWhite_: playerBlack), depth-1);
   _if (e >_eval) {
    _HitCurrent.coordPlayable_= [i,j];
 ___ eval_= e;
 __ }
__ }
   // Restore_arrayCurrent_array
   HitCurrent.arrayCurrent = JSON.parse(JSON.stringify(arrayTemp));
 _ }
 return eval;
}

From_this,_I would like to_use "inline" WebWorkers to dedicate_the recursion to WebWorker and avoid_hanging process_in browsers.
I_tried to follow this link and this other link
I don't know_if I have to "postmessage" the_object HitCurrent or the_value eval_to_the main thread_:_by using_WebWorker, I make confusions between the return_instruction (which_returns a value in the terminal_case) and the objet_HitCurrent_argument passed for next recursive call.
If_someone could give some clues to_reproduce this original algorithm by_using_inline_webworker (or with classical way_of using webworker).

A:

Inline webworker example:
As your_code, there is_no function evaluation, function