// ~2.3 MHz: slowed mostly by IsLegal() and only slightly by resetMove() protected Boolean tryMove(ref Move move, Boolean bFindRepetition = true, Boolean bQxnt = false) { CurrentMove = move; // Current Pseudo Move (bool bPrevented, bool bRestricted) = isPinned(move); if (bPrevented) // Skip moves which violate known pins { GameState.AtomicIncrement(ref State.PinSkipTotal); return(false); } //[Timer]timeMove(move); // //[Note]resetMove() is called here because it is needed for every subsequent move. This leaves // a window between the time initNode() initializes a node and when resetMove() is first called. // resetMove(); this.move(ref move); if (IsDraw0()) { clrEval(); // Captures and Pawn moves invalidate staticEval() } //[Note]If En Passant was possible, any move ends a Transposition Group if (Parent.IsPassed()) { setDraw0(); } testHash(); // Conditional var bLegal = IsLegal(bFindRepetition, bRestricted); if (isDefined(move)) { if (bLegal) { CurrentMove = move = annotateEarly(move); } else { restrictPiece(move); } } State.IncMove(bLegal, bQxnt); State.MonitorBound(this); // Pass position so heartbeat() can build getCurrentMoves() return(bLegal); }
protected Boolean nullMove() { CurrentMove = Move.NullMove; // Current Pseudo Move resetMove(); skipTurn(); //[Note]If En Passant was possible, any move ends a Transposition Group if (Parent.IsPassed()) { setDraw0(); } testHash(); // Conditional var bLegal = !InCheck(); if (!bLegal) { throw new BoardException("Illegal Null Move"); } GameState.AtomicIncrement(ref State.NullMoveTotal); State.MonitorBound(this); return(bLegal); }