private IEnumerable <MoveAndNodes> GetMovesAndNodeRoot(int depth) { if (depth == 0) { throw new ArgumentOutOfRangeException(nameof(depth), depth, null); } var possibleMoves = _moves[depth]; var moveCount = 0; _moveGenerator.GetAllLegalMoves(_currentBoard, possibleMoves, ref moveCount); for (var i = 0; i < moveCount; i++) { var move = possibleMoves[i]; //_currentBoard.TestMove(move); _currentBoard.DoMove2(move, false); //_eval.Evaluate(_currentBoard); var nodes = GetNodesInner(_currentBoard, depth - 1); //var nodes = 1; _currentBoard.UndoMove(false); var moveStr = move.ToPositionString(); var moveAndNodes = new MoveAndNodes(moveStr, nodes, move); yield return(moveAndNodes); } }
private IEnumerable <MoveAndNodes> FindMoveAndNodesFromSharperResultsInner(IEnumerable <string> sharperResults) { foreach (var result in sharperResults) { var split = result.Split(' '); if (split.Length != 2 || (split[0].Length != 4 && split[0].Length != 5)) { continue; } var man = new MoveAndNodes(split[0], int.Parse(split[1])); yield return(man); } }
public IList <MoveAndNodes> Divide(Board board, int depth) { var moves = PossibleMovesService.GetAllPossibleMoves(board); if (depth == 1) { return(moves.Select(x => new MoveAndNodes(x.ToPositionString(), 1)).OrderBy(x => x.Move).ToList()); } var results = new List <MoveAndNodes>(); Action <Move> act = m => { var moved = board.DoMove(m); var count = GetPossibleMoveCountInner(moved, depth, 2); var posStr = m.ToPositionString(); var man = new MoveAndNodes(posStr, count, m); lock (results) { results.Add(man); } }; if (MultiThreaded) { Parallel.ForEach(moves, act); } else { foreach (var move in moves) { act.Invoke(move); } } var ordered = results.OrderBy(x => x.Move).ToList(); return(ordered); }
public PerftComparisonResult(bool correctMove, bool correctNodes, MoveAndNodes perftResult = default) { CorrectMove = correctMove; CorrectNodes = correctNodes; PerftResult = perftResult; }