Esempio n. 1
0
 public BoundedVistedNodesCountStrategy(IPlayersState playersState, int maxVistedNOdesCount, MovesFactory movesFactory, Func <ISearchNodeVisitor <JumpNode>, ITreeSearch <JumpNode> > searchFactory)
 {
     _bruteForceSearch = new BruteForceMoveFindingStartegy(new StopOnVisitedNodesCount <JumpNode>(maxVistedNOdesCount),
                                                           searchFactory,
                                                           playersState,
                                                           movesFactory);
 }
Esempio n. 2
0
 public BoundedDepthMoveFindingStrategy(IPlayersState playersState, int maxDepth, MovesFactory movesFactory, Func <ISearchNodeVisitor <JumpNode>, ITreeSearch <JumpNode> > searchFactory)
 {
     _bruteForceSearch = new BruteForceMoveFindingStartegy(new StopOnDepthNodeVisitor <JumpNode>(maxDepth),
                                                           searchFactory,
                                                           playersState,
                                                           movesFactory);
 }
 public WaitingForPlayerMoveState(IPhutballBoard phutballBoard, MovesHistory movesHistory, IPlayersState playersState)
 {
     _phutballBoard = phutballBoard;
     _movesHistory = movesHistory;
     _playersState = playersState;
     _performMoves = new PerformMoves(phutballBoard, playersState);
 }
 public BoundedVistedNodesCountStrategy(IPlayersState playersState, int maxVistedNOdesCount, MovesFactory movesFactory, Func<ISearchNodeVisitor<JumpNode>, ITreeSearch<JumpNode>> searchFactory)
 {
     _bruteForceSearch = new BruteForceMoveFindingStartegy(new StopOnVisitedNodesCount<JumpNode>(maxVistedNOdesCount),
                                                           searchFactory,
                                                           playersState,
                                                           movesFactory);
 }
Esempio n. 5
0
 public WaitingForPlayerMoveState(IPhutballBoard phutballBoard, MovesHistory movesHistory, IPlayersState playersState)
 {
     _phutballBoard = phutballBoard;
     _movesHistory  = movesHistory;
     _playersState  = playersState;
     _performMoves  = new PerformMoves(phutballBoard, playersState);
 }
 public BoundedDepthMoveFindingStrategy(IPlayersState playersState, int maxDepth, MovesFactory movesFactory, Func<ISearchNodeVisitor<JumpNode>, ITreeSearch<JumpNode>> searchFactory)
 {
     _bruteForceSearch = new BruteForceMoveFindingStartegy(new StopOnDepthNodeVisitor<JumpNode>(maxDepth),
         searchFactory,
         playersState,
         movesFactory);
 }
Esempio n. 7
0
        public WhiteStoneToCurrentPlayerBorderDistance(IPlayersState playersState, IFieldsGraph fieldsGraph, int distanceToBorderWeight)
        {
            _distanceToBorderWeight = distanceToBorderWeight;
            var currentPlayer = playersState.CurrentPlayer;

            _targetBorder = currentPlayer.GetTargetBorder(fieldsGraph);
            _whiteStoneToBorderDistance = new WhiteStoneToBorderDistanceValue(_targetBorder);
        }
Esempio n. 8
0
 public AlphaBetaMoveFindingStrategy(IPlayersState playersState,
                                     IAlphaBetaOptions alphaBetaSearchDepth,
                                     Func <IFieldsGraph, IJumpNodeTree> movesFactory
                                     )
 {
     _playersState         = playersState;
     _alphaBetaSearchDepth = alphaBetaSearchDepth;
     _movesFactory         = movesFactory;
 }
Esempio n. 9
0
 public PhutballBoard(
     IPlayersState playerState,
     IFieldsGraph fieldsGraph,
     IEventPublisher eventPublisher,
     IPhutballOptions options) : base(fieldsGraph, options)
 {
     _playerState    = playerState;
     _eventPublisher = eventPublisher;
 }
 public AlphaBetaMoveFindingStrategy(IPlayersState playersState, 
     IAlphaBetaOptions alphaBetaSearchDepth,
     Func< IFieldsGraph,IJumpNodeTree> movesFactory
     )
 {
     _playersState = playersState;
     _alphaBetaSearchDepth = alphaBetaSearchDepth;
     _movesFactory = movesFactory;
 }
Esempio n. 11
0
 public BruteForceMoveFindingStartegy(ISearchNodeVisitor <JumpNode> defaultNodeVistor,
                                      Func <ISearchNodeVisitor <JumpNode>, IPerformMoves, TargetBorder, ITreeSearch <JumpNode> > searchFactory,
                                      IPlayersState playersState,
                                      MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory      = movesFactory;
     _searchFactory     = searchFactory;
     _playersState      = playersState;
 }
 public BruteForceMoveFindingStartegy(ISearchNodeVisitor<JumpNode> defaultNodeVistor, 
     Func<ISearchNodeVisitor<JumpNode>, IPerformMoves, TargetBorder,ITreeSearch<JumpNode>> searchFactory,
     IPlayersState playersState,
     MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory = movesFactory;
     _searchFactory = searchFactory;
     _playersState = playersState;
 }
Esempio n. 13
0
 public PhutballBoard(
     IPlayersState playerState,
     IFieldsGraph fieldsGraph,
     IEventPublisher eventPublisher,
     IPhutballOptions options)
     : base(fieldsGraph, options)
 {
     _playerState = playerState;
     _eventPublisher = eventPublisher;
 }
 public BruteForceMoveFindingStartegy(
     ISearchNodeVisitor<JumpNode> defaultNodeVistor,
     Func<ISearchNodeVisitor<JumpNode>,ITreeSearch<JumpNode>> searchFactory,
     IPlayersState playersState,
     MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory = movesFactory;
     _searchFactory = (visotors,perfomer, target) => searchFactory(visotors);
     _playersState = playersState;
 }
Esempio n. 15
0
 public PlaceBlackStonesForPlayer(
     IJumpNodeTreeWithFactory parent,
     IPlayersState playersState,
     Func <IPlaceBlackStone> blackStonePlacer)
 {
     _parent           = parent;
     _playersState     = playersState;
     _blackStonePlacer = blackStonePlacer;
     _parentJumpNode   = _parent.Node;
     _placersFactory   = new PlayerBlackStonePlacer(_parentJumpNode.ActualGraph, _playersState);
 }
Esempio n. 16
0
 public BruteForceMoveFindingStartegy(
     ISearchNodeVisitor <JumpNode> defaultNodeVistor,
     Func <ISearchNodeVisitor <JumpNode>, ITreeSearch <JumpNode> > searchFactory,
     IPlayersState playersState,
     MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory      = movesFactory;
     _searchFactory     = (visotors, perfomer, target) => searchFactory(visotors);
     _playersState      = playersState;
 }
 public CuttoffsMoveFindingStrategy(
     ISearchNodeVisitor<JumpNode> defaultNodeVistor,
     Func<ISearchNodeVisitor<JumpNode>, IPerformMoves, TargetBorder,ITreeSearch<JumpNode>> searchFactory,
     IPlayersState playersState,
     MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory = movesFactory;
     _searchFactory = searchFactory;
     _playersState = playersState;
     MaxVisitedNodes = int.MaxValue;
 }
 public PlayerSelectedFieldStateMove(
     IPhutballBoard phutballBoard,
     IPlayersState playersState,
     Field selectedField,
     MovesHistory movesHistory)
 {
     _phutballBoard = phutballBoard;
     _movesHistory = movesHistory;
     _playersState = playersState;
     _performMoves = new PerformMoves(phutballBoard, _playersState);
     _selectedField = selectedField;
 }
Esempio n. 19
0
 public CuttoffsMoveFindingStrategy(
     ISearchNodeVisitor <JumpNode> defaultNodeVistor,
     Func <ISearchNodeVisitor <JumpNode>, IPerformMoves, TargetBorder, ITreeSearch <JumpNode> > searchFactory,
     IPlayersState playersState,
     MovesFactory movesFactory)
 {
     _defaultNodeVistor = defaultNodeVistor;
     _movesFactory      = movesFactory;
     _searchFactory     = searchFactory;
     _playersState      = playersState;
     MaxVisitedNodes    = int.MaxValue;
 }
Esempio n. 20
0
 public PlayerSelectedFieldStateMove(
     IPhutballBoard phutballBoard,
     IPlayersState playersState,
     Field selectedField,
     MovesHistory movesHistory)
 {
     _phutballBoard = phutballBoard;
     _movesHistory  = movesHistory;
     _playersState  = playersState;
     _performMoves  = new PerformMoves(phutballBoard, _playersState);
     _selectedField = selectedField;
 }
Esempio n. 21
0
        protected override void EstablishContext()
        {
            _fieldsGraph  = GraphBuilder().Build();
            _playersState = PlayersState.SecondIsOnTheMove();
            _performMoves = new PerformMoves(_fieldsGraph, new NulloPlayersSwapper());
            var testPhutballOptions = new PhutballOptions
            {
                RowCount    = _fieldsGraph.RowCount,
                ColumnCount = _fieldsGraph.ColumnCount
            };

            _moveFinders = new RawMoveFinders(new MovesFactory(), _playersState, testPhutballOptions);
            ProvideImplementationOf <IPhutballOptions>(testPhutballOptions);
        }
Esempio n. 22
0
 public PhutballGameState(
     IEventPublisher eventPublisher,
     IPhutballBoard phutballBoard,
     IPlayersState playersState,
     BestMoveApplier bestMoveApplier,
     Func <IHandlePlayerMoves> handlePlayerMovesFactory)
 {
     _currentState             = PhutballGameStateEnum.NotStarted;
     _eventPublisher           = eventPublisher;
     _phutballBoard            = phutballBoard;
     _playersState             = playersState;
     _bestMoveApplier          = bestMoveApplier;
     _handlePlayerMovesFactory = handlePlayerMovesFactory;
     _handlePlayerMoves        = handlePlayerMovesFactory();
     _eventPublisher.Subscribe <PlayerWonEvent>((e) => CurrentPlayerWon());
     _eventPublisher.Subscribe <PlayerOnTheMoveChanged>(OnPlayerOnTheMoveChanged);
     _eventPublisher.Subscribe <ComputerStartedMoving>((e) => LongRunningProcess.Clear());
 }
Esempio n. 23
0
 public PhutballGameState(
     IEventPublisher eventPublisher,
     IPhutballBoard phutballBoard,
     IPlayersState playersState,
     BestMoveApplier bestMoveApplier,
     Func<IHandlePlayerMoves> handlePlayerMovesFactory)
 {
     _currentState = PhutballGameStateEnum.NotStarted;
     _eventPublisher = eventPublisher;
     _phutballBoard = phutballBoard;
     _playersState = playersState;
     _bestMoveApplier = bestMoveApplier;
     _handlePlayerMovesFactory = handlePlayerMovesFactory;
     _handlePlayerMoves = handlePlayerMovesFactory();
     _eventPublisher.Subscribe<PlayerWonEvent>((e)=> CurrentPlayerWon());
     _eventPublisher.Subscribe<PlayerOnTheMoveChanged>(OnPlayerOnTheMoveChanged);
     _eventPublisher.Subscribe<ComputerStartedMoving>((e)=> LongRunningProcess.Clear());
 }
Esempio n. 24
0
        protected IFieldsGraph AfterMoveOn(TestFieldsGraph graphToSearch)
        {
            var actualGraph = graphToSearch.Build();

            _playersState = PlayersState.SecondIsOnTheMove();
            var phutballOptions = new PhutballOptions()
            {
                RowCount    = actualGraph.RowCount,
                ColumnCount = actualGraph.ColumnCount
            };

            RawMoveFinders = new RawMoveFinders(new MovesFactory(), _playersState, phutballOptions);
            _performMoves  = new PerformMoves(actualGraph, new NulloPlayersSwapper());
            _strategy      = GetSearchStrategy();
            _bestMove      = _strategy.Search(actualGraph);
            if (_bestMove.Move != null)
            {
                _performMoves.Perform(_bestMove.Move);
            }
            return(actualGraph);
        }
Esempio n. 25
0
 public HandlePlayerMoves(WaitingForPlayerMoveState waitingForPlayerMoveState, IPlayersState playersState)
 {
     _waitForPlayerMoveState = waitingForPlayerMoveState;
     _playersState = playersState;
     _currentMoveState = _waitForPlayerMoveState;
 }
Esempio n. 26
0
 public FirstJumpThenPlaceStones(IJumpNodeTreeWithFactory parent, IAlphaBetaOptions options, IPlayersState playerState)
 {
     _parent      = parent;
     _options     = options;
     _playerState = playerState;
 }
Esempio n. 27
0
 public JumpCollectWhiteStonePlacesThenPutBlack(IJumpNodeTreeWithFactory parent, IAlphaBetaOptions options, IPlayersState playerState)
 {
     _parent      = parent;
     _options     = options;
     _playerState = playerState;
 }
Esempio n. 28
0
 public BlackStoneToTargetBorderCount(IPlayersState playersState, IFieldsGraph actualGraph, int goodBlackFieldsWeight)
 {
     _targetBorder          = playersState.CurrentPlayer.GetTargetBorder(actualGraph);
     _originalDistance      = _targetBorder.GetDistanceFrom(actualGraph.GetWhiteField());
     _goodBlackFieldsWeight = goodBlackFieldsWeight;
 }
Esempio n. 29
0
 public AverageBlackStoneToTargetBorderDistance(IPlayersState playersState, IFieldsGraph actualGraph, int averageDistanceWeight)
 {
     _targetBorder          = playersState.CurrentPlayer.GetTargetBorder(actualGraph);
     _originalDistance      = _targetBorder.GetDistanceFrom(actualGraph.GetWhiteField());
     _averageDistanceWeight = averageDistanceWeight;
 }
Esempio n. 30
0
 public RawMoveFinders(MovesFactory movesFactory, IPlayersState playersState, IPhutballOptions phutballOptions)
 {
     _movesFactory     = movesFactory;
     _playersStateCopy = () => playersState.CopyRestarted();
     _phutballOptions  = phutballOptions;
 }
 public PlayerBlackStonePlacer(IFieldsGraph fieldsGraph, IPlayersState playersState)
 {
     _fieldsGraph = fieldsGraph;
     _playersState = playersState;
 }
Esempio n. 32
0
 public HandlePlayerMoves(WaitingForPlayerMoveState waitingForPlayerMoveState, IPlayersState playersState)
 {
     _waitForPlayerMoveState = waitingForPlayerMoveState;
     _playersState           = playersState;
     _currentMoveState       = _waitForPlayerMoveState;
 }
Esempio n. 33
0
 public RawMoveFinders(MovesFactory movesFactory, IPlayersState playersState, IPhutballOptions phutballOptions)
 {
     _movesFactory = movesFactory;
     _playersStateCopy  = ()=>playersState.CopyRestarted();
     _phutballOptions = phutballOptions;
 }
Esempio n. 34
0
 public CuttoffPickBestValueNodeVisitor(TargetBorder targetBorder, IFieldsGraph fieldsGraph, IPlayersState playersState)
 {
     _targetBorder  = targetBorder;
     _fieldsGraph   = fieldsGraph;
     MovesPerformer = new PerformMoves(this, playersState);
     PickBestValue  = new PickBestValueNodeVisitor(targetBorder, fieldsGraph, MovesPerformer);
     InitliazeBlackBuckets(fieldsGraph);
     PickBestValue.MaxUpdated += OnBestPositionUpdated;
     _targetBorderRowEndIndex  = _targetBorder.EndRowIndex;
 }
Esempio n. 35
0
 public PlayerBlackStonePlacer(IFieldsGraph fieldsGraph, IPlayersState playersState)
 {
     _fieldsGraph  = fieldsGraph;
     _playersState = playersState;
 }