public TranspositionNode(NodeType nodeType, int score, int depth, Move bestMove, PVList pv) { NodeType = nodeType; Score = score; Depth = depth; BestMove = bestMove; PV = pv; }
public TTHit TryGetValue(ulong key, int depth, int alpha, int beta, PVList currentPV) { TTHit hit = new TTHit(); hit.HitType = HitType.Miss; bool found = table.TryGetValue(key, out hit.TTNode); if (found) { hit.HitType = HitType.Useless; if (hit.TTNode.Depth >= depth) { switch (hit.TTNode.NodeType) { case NodeType.CutNode: if (hit.TTNode.Score >= beta) { hit.HitType = HitType.Hit; hit.Score = beta; } break; case NodeType.AllNode: if (hit.TTNode.Score <= alpha) { hit.HitType = HitType.Hit; hit.Score = alpha; } break; case NodeType.PVNode: hit.HitType = HitType.Hit; hit.Score = hit.TTNode.Score; currentPV.Replace(hit.TTNode.PV); break; } } else if (hit.TTNode.Depth >= depth - engineConfig.NullMoveDepthReduction && hit.TTNode.NodeType != NodeType.CutNode && hit.TTNode.Score < beta) { hit.HitType = HitType.AvoidNullMove; } } return(hit); }