Exemplo n.º 1
0
        public void should_generate_moves_properly()
        {
            _fieldsGraph = new TestFieldsGraph(
                new[]
            {
                new[] { Empty, Empty, Empty, Empty, Empty },
                new[] { Empty, Empty, Empty, Empty, Empty },
                new[] { Empty, Empty, Black, Empty, Empty },
                new[] { Empty, Empty, Black, Empty, Empty },
                new[] { Empty, Empty, Empty, Empty, Empty },
                new[] { Empty, Empty, Black, Empty, Empty },
                new[] { Empty, Empty, White, Empty, Empty },
                new[] { Empty, Empty, Empty, Empty, Empty },
                new[] { Empty, Empty, Empty, Empty, Empty },
                new[] { Empty, Empty, Empty, Empty, Empty },
            }
                ).Build();

            var current      = new RootedBySelectingWhiteFieldBoardJumpTree(_fieldsGraph);
            var currentMoves =
                current.TraverseDfs(
                    new PerformMovesNodeVisitor(PerformMoves.DontCareAboutPlayerStateChange(_fieldsGraph)))
                .Skip(1).ToList();

            currentMoves.ShouldHaveCount(2);
        }
Exemplo n.º 2
0
        public IEnumerator <IJumpNodeTreeWithFactory> GetEnumerator()
        {
            var actualGraph        = (IFieldsGraph)_parentJumpNode.ActualGraph.Clone();
            var localMovePerformer = PerformMoves.DontCareAboutPlayerStateChange(actualGraph);
            var current            = new RootedBySelectingWhiteFieldBoardJumpTree(actualGraph);
            var visitor            = new PerformMovesNodeVisitor(localMovePerformer).FollowedBy(_afterMoveVisitor);
            var currentMoves       = current.TraverseDfs(visitor, _alphaBetaOptions.JumpsMaxDepth)
                                     .Skip(_alphaBetaOptions.SkipShortMoves);

            foreach (var currentMove in currentMoves)
            {
                var newMove  = CreateNewMove(currentMove);
                var jumpNode = _parentJumpNode.FollowedBy(newMove);
                yield return(new AlternatingJumpsMovesTree(jumpNode, Parent.ChildFactory));
            }
        }