ai
other019
0 Likes0 Commentsjavascriptclass GameAi{ constructor(){ //initcall //minimax (currentPos,3,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,true); } gameAssesState(position){ //algorytm oceniania stanug gry //wyższa ocena im bliżej do celu //prawdopodbne poziomy inteligencji // 8**3 = 512 liści // 8**5 = 32768 liści // 8**7 = 2097152 liści } isGameOver(position){ } minimax(position,depth,alpha,beta,maximizingPlayer){ if (depth == 0 || isGameOver(position)) return gameAssesState(position); if (maximizingPlayer){ var maxEval = Number.NEGATIVE_INFINITY; var childs = getChilds(position); child.forEach( function(child){ var eval = minimax(child,depth-1,alpha,beta,false); maxEval = Math.max(maxEval,eval); alpha = Math.max(alpha,eval); if (beta<=alpha){ break; } } ); return maxEval; } else{ var minEval = } } }