Exemple #1
0
        /// <summary>
        /// ターゲットとなるタイルの矩形を取得(MainWindowからの座標)
        /// </summary>
        /// <returns></returns>
        private Rect GetTileRect()
        {
            Rect rect = new Rect();

            if (TargetBorder == null)
            {
                return(rect);
            }

            // 大きさ
            double zoomFactor = MainWindow.MainContent.LayoutTransform.Value.M11;

            rect.Width   = TargetBorder.RenderSize.Width + TargetBorder.Margin.Left * 2;
            rect.Height  = TargetBorder.RenderSize.Height + TargetBorder.Margin.Top * 2;
            rect.Width  *= zoomFactor;
            rect.Height *= zoomFactor;

            // 位置
            var parent   = TargetBorder.Parent as UIElement;
            var location = TargetBorder.TranslatePoint(new Point(0, 0), parent);

            location.X -= TargetBorder.Margin.Left;
            location.Y -= TargetBorder.Margin.Top;
            location.X += ParentContainer.Margin.Left; // コンテナのスライド量を反映
            location.Y += ParentContainer.Margin.Top;
            location.X *= zoomFactor;
            location.Y *= zoomFactor;
            location.X += MainWindow.MainContent.Margin.Left; // メインウインドウ枠の分
            location.Y += MainWindow.MainContent.Margin.Top;

            rect.X = location.X;
            rect.Y = location.Y;

            return(rect);
        }
Exemple #2
0
        public WhiteStoneToCurrentPlayerBorderDistance(IPlayersState playersState, IFieldsGraph fieldsGraph, int distanceToBorderWeight)
        {
            _distanceToBorderWeight = distanceToBorderWeight;
            var currentPlayer = playersState.CurrentPlayer;

            _targetBorder = currentPlayer.GetTargetBorder(fieldsGraph);
            _whiteStoneToBorderDistance = new WhiteStoneToBorderDistanceValue(_targetBorder);
        }
Exemple #3
0
 public PickBestValueNodeVisitor(TargetBorder targetBorder, IFieldsGraph graphCopy, IPerformMoves performMoves)
 {
     _targetBorder   = targetBorder;
     _valueOfGraph   = new WhiteStoneToBorderDistanceValue(targetBorder);
     _graphCopy      = graphCopy;
     _performMoves   = performMoves;
     CurrentMaxValue = _valueOfGraph.GetValue(_graphCopy);
     MaxUpdated     += () => { };
 }
Exemple #4
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;
 }
        public TargetBorderEnum(IFieldsGraph fieldsGraph)
        {
            Upper = new TargetBorder(() => 1, UpperName)
                .OppositeIs(() => Bottom)
                .CountDistanceUsing(new DistanceToUpperBorderCounter(fieldsGraph))
                .ComparePositionsUsing((left,right)=> left < right)
                .EndRowIndexIs(me=> 1)
                .WiningIndexes((me)=> new[]{0,1});

            Bottom = new TargetBorder(() => fieldsGraph.RowCount - 2, Bottomname)
                .OppositeIs(() => Upper)
                .CountDistanceUsing(new DistanceToBottomBorderCounter(fieldsGraph))
                .EndRowIndexIs((me)=> me.RowIndex )
                .ComparePositionsUsing((left, right) => left > right)
                .WiningIndexes((me)=> new[]{me.RowIndex, me.RowIndex + 1});
        }
Exemple #6
0
        public int GetValue(T valueSubject)
        {
            var leftValue = _left.GetValue(valueSubject);

            if (TargetBorder.IsWinOrLooseValue(leftValue))
            {
                return(leftValue);
            }
            var rightValue = _right.GetValue(valueSubject);

            if (rightValue == TargetBorder.WinValueConst)
            {
                return(rightValue);
            }
            return(leftValue + rightValue);
        }
Exemple #7
0
        public TargetBorderEnum(IFieldsGraph fieldsGraph)
        {
            Upper = new TargetBorder(() => 1, UpperName)
                    .OppositeIs(() => Bottom)
                    .CountDistanceUsing(new DistanceToUpperBorderCounter(fieldsGraph))
                    .ComparePositionsUsing((left, right) => left < right)
                    .EndRowIndexIs(me => 1)
                    .WiningIndexes((me) => new[] { 0, 1 });

            Bottom = new TargetBorder(() => fieldsGraph.RowCount - 2, Bottomname)
                     .OppositeIs(() => Upper)
                     .CountDistanceUsing(new DistanceToBottomBorderCounter(fieldsGraph))
                     .EndRowIndexIs((me) => me.RowIndex)
                     .ComparePositionsUsing((left, right) => left > right)
                     .WiningIndexes((me) => new[] { me.RowIndex, me.RowIndex + 1 });
        }
 public WhiteStoneToBorderDistanceValue(TargetBorder winingBorder)
 {
     _winingBorder = winingBorder;
 }
Exemple #9
0
 protected override WhiteStoneToBorderDistanceValue CreateSut()
 {
     _targetBorder = GetTargetBorder();
     return(new WhiteStoneToBorderDistanceValue(_targetBorder));
 }