public KeyValuePair <Move, int> RunPNS(NodeTree root, int depht, bool isInitial, bool isMaximizing, Stopwatch timer) { searchCount = 0; root.nodeScore = root.Evaluation(); root.setPNS(); //ExpandNode (root/*, depht*/); SetProofAndDisproof(root); NodeTree currentNode = root; //int depthTmp = depth; while (root.proof != 0 && root.disproof != 0 && timer.ElapsedMilliseconds < 2500 * depth) { NodeTree mostProving = SelectMostProvingNode(currentNode, depht); ExpandNode(mostProving, depth); //Console.WriteLine ("expanded"); //searchCount += mostProving.children.Count; currentNode = UpdateAncestors(root, currentNode); //Console.WriteLine ("Ancestor update"); } NodeTree selectedChild = null; int mostProvingValue = int.MaxValue; //You want the lowest proof number List <Move> legalMoves = root.board.getPlayerMoves(player); Console.WriteLine("nb de coup pour root : " + legalMoves.Count + "\nnb root children : " + root.children.Count); SetProofAndDisproof(root); for (int i = 0; i < root.children.Count; i++) { if (root.children[i].pns == PNS.PROVEN) { selectedChild = root.children[i]; Console.WriteLine("THIS should be winning move"); break; } else { if (mostProvingValue > root.children[i].proof) { //Console.Write ("new best proving assignation"); mostProvingValue = root.children[i].proof; selectedChild = root.children[i]; } } } Console.WriteLine("score : " + mostProvingValue); //root.PrintTree ("", true); return(new KeyValuePair <Move, int> (selectedChild.move, selectedChild.nodeScore)); }