コード例 #1
0
ファイル: BoundTests.cs プロジェクト: jyunfan2015/forge
        public void AwayFromOrigin() {
            Bound b1 = new Bound(500, 0, 10);
            Bound b2 = new Bound(495, 0, 1);

            Assert.True(b1.Intersects(b2));
            Assert.True(b2.Intersects(b1));
        }
コード例 #2
0
ファイル: Bound.cs プロジェクト: markiemarkus/QuadProg
 protected void Validate(Bound bound)
 {
     if (bound.Position != this.position)
     {
         throw new System.IndexOutOfRangeException("Bound positions do not agree.");
     }
 }
コード例 #3
0
ファイル: BoundTests.cs プロジェクト: jyunfan2015/forge
        public void FullyContained() {
            Bound b1 = new Bound(0, 0, 30);
            Bound b2 = new Bound(0, 0, 1);

            Assert.True(b1.Intersects(b2));
            Assert.True(b2.Intersects(b1));
        }
コード例 #4
0
ファイル: BoundTests.cs プロジェクト: jyunfan2015/forge
        public void NotIntersecting() {
            Bound b1 = new Bound(0, 0, 1);
            Bound b2 = new Bound(10, 10, 1);

            Assert.False(b1.Intersects(b2));
            Assert.False(b2.Intersects(b1));
        }
コード例 #5
0
ファイル: BoundTests.cs プロジェクト: jyunfan2015/forge
        public void IntersectingEdge() {
            Bound b1 = new Bound(0, 0, 5);
            Bound b2 = new Bound(0, 5, 1);

            Assert.True(b1.Intersects(b2));
            Assert.True(b2.Intersects(b1));
        }
コード例 #6
0
ファイル: GoodStar.cs プロジェクト: goodmaker/gooddrawer
 public GoodStar(int NumberOfTops, double lenghtCoef, Bound b)
     : base(b)
 {
     Name = "Star";
        _numberOfBeams = NumberOfTops;
        this._lengthCoef = lenghtCoef;
        tops = new System.Windows.Point[NumberOfTops * 2];
 }
コード例 #7
0
ファイル: GoodShapes.cs プロジェクト: goodmaker/gooddrawer
 public GoodShapesCollection(Bound b, GoodShape[] shapes )
     : base(b)
 {
     this.shapes.AddRange(shapes);
     geometry = new GeometryGroup();
     foreach (GoodShape s in shapes)
         ((GeometryGroup)geometry).Children.Add(s.geometry);
 }
コード例 #8
0
ファイル: GoodRectangle.cs プロジェクト: goodmaker/gooddrawer
 public GoodRectangle(Bound b, double xRad, double yRad)
     : base(b)
 {
     Name = "Rectangle";
     xRadius = xRad;
     yRadius = yRad;
     tops = new System.Windows.Point[4];
 }
コード例 #9
0
	private void Enter()
	{
		DisplayText.SetDisplayText (DetermineTextToDisplay());
		activeBound = this;

		if(jukebox != null) {
			jukebox.Play ();
		}
	}
コード例 #10
0
ファイル: BoundTest.cs プロジェクト: skonves/Collections
 public void MinxTest_SameValues()
 {
     IBound<int> a = new Bound<int>(5, BoundType.Exclusive);
     IBound<int> b = new Bound<int>(5, BoundType.Inclusive);
     IBound<int> expected = b;
     IBound<int> actual;
     actual = Bound<int>.Min(a, b);
     Assert.AreEqual(expected, actual);
 }
コード例 #11
0
ファイル: BoundTest.cs プロジェクト: skonves/Collections
 public void MinTest_DifferentValues()
 {
     IBound<int> a = new Bound<int>(2, BoundType.Inclusive);
     IBound<int> b = new Bound<int>(5, BoundType.Inclusive);
     IBound<int> expected = a;
     IBound<int> actual;
     actual = Bound<int>.Min(a, b);
     Assert.AreEqual(expected, actual);
 }
コード例 #12
0
ファイル: TT.cs プロジェクト: torfranz/Portfish
 internal void save(uint k, int v, Bound t, int d, int m, int g, Value statV, Value statM)
 {
     this.key = k;
     this.move16 = (ushort)m;
     this.bound = (byte)t;
     this.generation8 = (byte)g;
     this.value16 = (short)v;
     this.depth16 = (short)d;
     this.evalValue = (short)statV;
     this.evalMargin = (short)statM;
 }
コード例 #13
0
ファイル: TT.cs プロジェクト: CVChrisWilson/Portfish
 internal void save(UInt32 k, Value v, Bound t, Depth d, Move m, int g, Value statV, Value statM)
 {
     key = k;
     move16 = (UInt16)m;
     bound = (byte)t;
     generation8 = (byte)g;
     value16 = (Int16)v;
     depth16 = (Int16)d;
     staticValue = (Int16)statV;
     staticMargin = (Int16)statM;
 }
コード例 #14
0
	public static void DisplayPrompt(Prompt p, Bound f)
	{
		prompt = p;
		if (p.button != null) {
			promptText.text = p.button.ToUpper () + " - " + p.text.ToUpper ();
		} else {
			promptText.text = p.text.ToUpper ();
		}
		promptText.enabled = true;
		callback = f;
	}
コード例 #15
0
ファイル: GoodShape.cs プロジェクト: goodmaker/gooddrawer
        public GoodShape(Bound b)
        {
            bound = b;
            if (b != null)
            {
                bound.ChildShape = this;
                //  VisualTransform = Bounds.Transform;
                b.BoundChanged += b_BoundChanged;
            }

            BorderPen = new Pen(Brushes.Black, 1);
        }
コード例 #16
0
ファイル: GoodShape.cs プロジェクト: goodmaker/gooddrawer
 public GoodShape(SerializationInfo info, StreamingContext context)
 {
     bound = (Bound)info.GetValue("Bound", typeof(Bound));
     if (bound != null)
     {
         bound.ChildShape = this;
         //  VisualTransform = Bounds.Transform;
         bound.BoundChanged += b_BoundChanged;
     }
     BorderPen = (Pen)info.GetValue("BorderPen", typeof(Pen));
     Color = (Brush)info.GetValue("Color", typeof(Brush));
 }
コード例 #17
0
ファイル: IntervalTest.cs プロジェクト: skonves/Collections
 public void ContainsTest_Bound_ExclusiveOnUpperExclusive()
 {
     int lowerBound = 2;
     BoundType lowerBoundType = BoundType.Inclusive;
     int upperBound = 5;
     BoundType upperBoundType = BoundType.Exclusive;
     Interval<int> target = new Interval<int>(lowerBound, lowerBoundType, upperBound, upperBoundType);
     IBound<int> bound = new Bound<int>(5, BoundType.Exclusive);
     bool expected = true;
     bool actual;
     actual = target.Contains(bound);
     Assert.AreEqual(expected, actual);
 }
コード例 #18
0
	private void Exit()
	{
		if (activeBound == this) {
			DisplayText.ClearDisplayText ();
			activeBound = null;

			PromptPrefab.HidePrompt ();
		}

		if (jukebox != null) {
			jukebox.StopPlaying ();
		}
	}
コード例 #19
0
        private void AddBoundModelToRoot()
        {
            Vector3 LBNCoordinates = Bound.GetLocalSpaceMin();
            Vector3 RTFCoordinates = Bound.GetLocalSpaceMax();

            float[,] renderCoordinates = new float[24, 3];

            renderCoordinates[0, 0] = LBNCoordinates.X; renderCoordinates[0, 1] = LBNCoordinates.Y; renderCoordinates[0, 2] = LBNCoordinates.Z;
            renderCoordinates[1, 0] = RTFCoordinates.X; renderCoordinates[1, 1] = LBNCoordinates.Y; renderCoordinates[1, 2] = LBNCoordinates.Z;
            renderCoordinates[2, 0] = RTFCoordinates.X; renderCoordinates[2, 1] = RTFCoordinates.Y; renderCoordinates[2, 2] = LBNCoordinates.Z;
            renderCoordinates[3, 0] = LBNCoordinates.X; renderCoordinates[3, 1] = RTFCoordinates.Y; renderCoordinates[3, 2] = LBNCoordinates.Z;

            renderCoordinates[4, 0] = RTFCoordinates.X; renderCoordinates[4, 1] = LBNCoordinates.Y; renderCoordinates[4, 2] = LBNCoordinates.Z;
            renderCoordinates[5, 0] = RTFCoordinates.X; renderCoordinates[5, 1] = LBNCoordinates.Y; renderCoordinates[5, 2] = RTFCoordinates.Z;
            renderCoordinates[6, 0] = RTFCoordinates.X; renderCoordinates[6, 1] = RTFCoordinates.Y; renderCoordinates[6, 2] = RTFCoordinates.Z;
            renderCoordinates[7, 0] = RTFCoordinates.X; renderCoordinates[7, 1] = RTFCoordinates.Y; renderCoordinates[7, 2] = LBNCoordinates.Z;

            renderCoordinates[8, 0]  = RTFCoordinates.X; renderCoordinates[8, 1] = LBNCoordinates.Y; renderCoordinates[8, 2] = RTFCoordinates.Z;
            renderCoordinates[9, 0]  = LBNCoordinates.X; renderCoordinates[9, 1] = LBNCoordinates.Y; renderCoordinates[9, 2] = RTFCoordinates.Z;
            renderCoordinates[10, 0] = LBNCoordinates.X; renderCoordinates[10, 1] = RTFCoordinates.Y; renderCoordinates[10, 2] = RTFCoordinates.Z;
            renderCoordinates[11, 0] = RTFCoordinates.X; renderCoordinates[11, 1] = RTFCoordinates.Y; renderCoordinates[11, 2] = RTFCoordinates.Z;

            renderCoordinates[12, 0] = LBNCoordinates.X; renderCoordinates[12, 1] = LBNCoordinates.Y; renderCoordinates[12, 2] = RTFCoordinates.Z;
            renderCoordinates[13, 0] = LBNCoordinates.X; renderCoordinates[13, 1] = LBNCoordinates.Y; renderCoordinates[13, 2] = LBNCoordinates.Z;
            renderCoordinates[14, 0] = LBNCoordinates.X; renderCoordinates[14, 1] = RTFCoordinates.Y; renderCoordinates[14, 2] = LBNCoordinates.Z;
            renderCoordinates[15, 0] = LBNCoordinates.X; renderCoordinates[15, 1] = RTFCoordinates.Y; renderCoordinates[15, 2] = RTFCoordinates.Z;

            renderCoordinates[16, 0] = LBNCoordinates.X; renderCoordinates[16, 1] = LBNCoordinates.Y; renderCoordinates[16, 2] = LBNCoordinates.Z;
            renderCoordinates[17, 0] = RTFCoordinates.X; renderCoordinates[17, 1] = LBNCoordinates.Y; renderCoordinates[17, 2] = LBNCoordinates.Z;
            renderCoordinates[18, 0] = RTFCoordinates.X; renderCoordinates[18, 1] = LBNCoordinates.Y; renderCoordinates[18, 2] = RTFCoordinates.Z;
            renderCoordinates[19, 0] = LBNCoordinates.X; renderCoordinates[19, 1] = LBNCoordinates.Y; renderCoordinates[19, 2] = RTFCoordinates.Z;

            renderCoordinates[20, 0] = LBNCoordinates.X; renderCoordinates[20, 1] = RTFCoordinates.Y; renderCoordinates[20, 2] = LBNCoordinates.Z;
            renderCoordinates[21, 0] = RTFCoordinates.X; renderCoordinates[21, 1] = RTFCoordinates.Y; renderCoordinates[21, 2] = LBNCoordinates.Z;
            renderCoordinates[22, 0] = RTFCoordinates.X; renderCoordinates[22, 1] = RTFCoordinates.Y; renderCoordinates[22, 2] = RTFCoordinates.Z;
            renderCoordinates[23, 0] = LBNCoordinates.X; renderCoordinates[23, 1] = RTFCoordinates.Y; renderCoordinates[23, 2] = RTFCoordinates.Z;

            var vao = new VertexArrayObject();

            var verticesVBO = new VertexBufferObjectTwoDimension <float>(renderCoordinates, BufferTarget.ArrayBuffer, 0, 3, VertexBufferObjectBase.DataCarryFlag.Store);

            vao.AddVBO(verticesVBO);
            vao.BindBuffersToVao();

            skin = new Skin(vao);
            PoolCollector.GetInstance().s_ModelPool.AddModelToRoot(skin, "CollisionBound");
        }
コード例 #20
0
ファイル: FragDrawable.cs プロジェクト: indilo53/gta-toolkit
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            // read structure data
            this.Unknown_A8h         = reader.ReadUInt32();
            this.Unknown_ACh         = reader.ReadUInt32();
            this.Unknown_B0h         = reader.ReadBlock <RAGE_Matrix4>();
            this.BoundPointer        = reader.ReadUInt64();
            this.Unknown_F8h_Pointer = reader.ReadUInt64();
            this.Count1               = reader.ReadUInt16();
            this.Count2               = reader.ReadUInt16();
            this.Unknown_104h         = reader.ReadUInt32();
            this.Unknown_108h_Pointer = reader.ReadUInt64();
            this.Count3               = reader.ReadUInt16();
            this.Count4               = reader.ReadUInt16();
            this.Unknown_114h         = reader.ReadUInt32();
            this.Unknown_118h         = reader.ReadUInt32();
            this.Unknown_11Ch         = reader.ReadUInt32();
            this.Unknown_120h         = reader.ReadUInt32();
            this.Unknown_124h         = reader.ReadUInt32();
            this.Unknown_128h         = reader.ReadUInt32();
            this.Unknown_12Ch         = reader.ReadUInt32();
            this.NamePointer          = reader.ReadUInt64();
            this.Unknown_138h         = reader.ReadUInt32();
            this.Unknown_13Ch         = reader.ReadUInt32();
            this.Unknown_140h         = reader.ReadUInt32();
            this.Unknown_144h         = reader.ReadUInt32();
            this.Unknown_148h         = reader.ReadUInt32();
            this.Unknown_14Ch         = reader.ReadUInt32();

            // read reference data
            this.Bound = reader.ReadBlockAt <Bound>(
                this.BoundPointer // offset
                );
            this.Unknown_F8h_Data = reader.ReadBlockAt <ResourceSimpleArray <ulong_r> >(
                this.Unknown_F8h_Pointer, // offset
                this.Count1
                );
            this.Unknown_108h_Data = reader.ReadBlockAt <ResourceSimpleArray <RAGE_Matrix4> >(
                this.Unknown_108h_Pointer, // offset
                this.Count2
                );
            this.Name = reader.ReadBlockAt <string_r>(
                this.NamePointer // offset
                );
        }
コード例 #21
0
                ///-------------------------------------------------------------
                public MeshContainer(int capacity, MeshRenderer renderer, int borderThickness)
                {
                    this.bounds = new Bound()
                    {
                        b = new Bounds()
                    };
                    this.renderer          = renderer;
                    this.filter            = renderer.GetComponent <MeshFilter>();
                    this.mesh              = new Mesh();
                    this.mesh.name         = "DebugLineMesh";
                    this.filter.sharedMesh = this.mesh;
                    this.borderThickness   = borderThickness + 1;

                    vertices  = null;
                    triangles = null;
                    RefreshMesh(capacity, borderThickness);
                }
コード例 #22
0
        protected override Bound LayoutChildren(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            _behaviour.ScrolledMeasure = styleBound.Width;

            Bound bound = LayoutBehaviour.Horizontal(stylesheet, this, _controls, styleBound, maxBound, true);

            if (_controls.Count > 0)
            {
                _behaviour.Borders.Add(_controls [0].Frame.Left);
                foreach (var control in _controls)
                {
                    _behaviour.Borders.Add(control.Frame.Right);
                }
            }

            return(bound);
        }
コード例 #23
0
        public static bool Verify(ReadOnlyPacket packet, int protocolVersion, Bound bound, bool hasForge, out PluginChannelPacket pcp)
        {
            if (packet is null)
            {
                throw new ArgumentNullException(nameof(packet));
            }
            if (protocolVersion < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(protocolVersion), "协议版本不能使用负数");
            }

            pcp = null;
            if ((bound.HasFlag(Bound.Client) && packet.ID != GetPacketID(protocolVersion, Bound.Client)) ||
                (bound.HasFlag(Bound.Server) && packet.ID != GetPacketID(protocolVersion, Bound.Server)))
            {
                return(false);
            }

            try
            {
                ReadOnlySpan <byte> buffer = packet.Data.ToSpan();
                pcp = new PluginChannelPacket(
                    packetID: packet.ID,
                    protocolVersion: protocolVersion,
                    hasForge: hasForge,
                    channel: buffer.AsString(out buffer));

                if (protocolVersion <= ProtocolVersionNumbers.V14w31a && hasForge)
                {
                    pcp.Data.AddRange(buffer.Slice(VarShort.GetLength(buffer)).ToArray());
                }
                else if (protocolVersion <= ProtocolVersionNumbers.V14w31a)
                {
                    pcp.Data.AddRange(buffer.Slice(2).ToArray());
                }
                else
                {
                    pcp.Data.AddRange(buffer.ToArray());
                }

                return(true);
            }
            catch (ArgumentOutOfRangeException) { return(false); }
            catch (IndexOutOfRangeException) { return(false); }
            catch (OverflowException) { return(false); }
        }
コード例 #24
0
 internal static RealPolynomialFunction1D[] quadraticsFirstDerivative(double[] x, double[] y, int intervalCount)
 {
     if (intervalCount == 1)
     {
         double b = (y[1] - y[0]) / (x[1] - x[0]);
         return(new RealPolynomialFunction1D[] { new RealPolynomialFunction1D(b) });
     }
     else
     {
         RealPolynomialFunction1D[] quadraticFirstDerivative = new RealPolynomialFunction1D[intervalCount - 1];
         for (int i = 1; i < intervalCount; i++)
         {
             quadraticFirstDerivative[i - 1] = Bound.quadraticFirstDerivative(x, y, i);
         }
         return(quadraticFirstDerivative);
     }
 }
コード例 #25
0
            public Bound Apply(StyleSheet stylesheet, Bound styleBound, Bound maxBound)
            {
                float w = styleBound.Width;
                float h = styleBound.Height;

                if (SizeToContentWidth && ContentWidth > w)
                {
                    w = ContentWidth > maxBound.Width ? maxBound.Width : ContentWidth;
                }

                if (SizeToContentHeight && ContentHeigth > h)
                {
                    h = ContentHeigth > maxBound.Height ? maxBound.Height : ContentHeigth;
                }

                return(new Bound(w, h));
            }
コード例 #26
0
        public void Update(double delta, double timescale, double correction, Bound bounds)
        {
            if (Math.Sign(Mass) == 0)
            {
                return;
            }


            var deltaTimeSquared = Math.Pow(delta * timescale * Timescale, 2);

            var frictionAir   = 1 - FrictionAir * timescale * Timescale;
            var velocityPrevX = Position.X - PositionPrev.X;
            var velocityPrevY = Position.Y - PositionPrev.Y;

            Velocity.X = velocityPrevX * frictionAir * correction + Force.X / Mass * deltaTimeSquared;
            Velocity.Y = velocityPrevY * frictionAir * correction + Force.Y / Mass * deltaTimeSquared;

            PositionPrev.X = Position.X;
            PositionPrev.Y = Position.Y;
            Position.X    += Velocity.X;
            Position.Y    += Velocity.Y;

            //_angularVelocity = (Angle - AnglePrev) * frictionAir * correction + Torque / Inertia * deltaTimeSquared;
            AnglePrev = Angle;
            Angle    += AngularVelocity;

            Speed        = Velocity.Magnitude();
            AngularSpeed = Math.Abs(AngularVelocity);

            for (var i = 0; i < _parts.Count; i++)
            {
                var part = _parts[i];
                part.Vertices.Translate(Velocity);
                if (i > 0)
                {
                    part._position.Offset(Velocity);
                }
                part.Vertices.Rotate(AngularVelocity, Position);
                part.Axes.Rotate(AngularVelocity);
                if (i > 0)
                {
                    part._position.RotateAbout(AngularVelocity, _position);
                }
                part.Bounds.Update(Vertices, Velocity);
            }
        }
コード例 #27
0
        /// <summary>
        /// Stores a move in the transposition table.
        /// It will automatically detect the best cluster location to store it in.
        /// If a similar move already is present, a simple check if done to make sure
        /// it actually is an improvement of the previous move.
        /// </summary>
        /// <param name="key">The position key</param>
        /// <param name="value">The value of the move</param>
        /// <param name="type">The bound type, e.i. did it exceed alpha or beta</param>
        /// <param name="depth">The depth of the move</param>
        /// <param name="move">The move it self</param>
        /// <param name="statValue">The static value of the move</param>
        public void Store(ulong key, int value, Bound type, sbyte depth, Move move, int statValue)
        {
            // Use the high 32 bits as key inside the cluster
            var e = new TranspositionTableEntry((uint)(key >> 32), move, depth, _generation, value, statValue, type);

            var ttc = FindCluster(key);

            var clusterIndex = 0;
            var found        = false;

            for (var i = 0; i < ttc.Cluster.Length; ++i)
            {
                if (ttc.Cluster[i].Key32 == 0 || ttc.Cluster[i].Key32 == e.Key32)
                {
                    clusterIndex = i;
                    found        = true;
                    break;
                }
            }

            if (!found)
            {
                var index     = 0;
                var candidate = ttc.Cluster[index];
                var g         = _generation;
                for (var i = 0; i < ttc.Cluster.Length; ++i)
                {
                    var ttEntry = ttc.Cluster[i];
                    var(cc1, cc2, cc3, cc4) =
                        (candidate.Generation == g,
                         ttEntry.Generation == g,
                         ttEntry.Type == Bound.Exact,
                         ttEntry.Depth < candidate.Depth);

                    if (cc1 && cc4 || !(cc2 || cc3) && (cc4 || cc1))
                    {
                        index     = i;
                        candidate = ttEntry;
                    }
                }

                clusterIndex = index;
            }

            ttc.Cluster[clusterIndex].Save(e);
        }
コード例 #28
0
ファイル: Image.cs プロジェクト: Fedorm/core-master
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            var style = stylesheet.GetHelper <StyleHelper>();

            // background image
            if (Source == null)
            {
                var background = style.Background(this, _applicationContext);
                _view.SetBackgroundDrawable(background);
            }

            //selected color
            _selectedColor = style.Color <SelectedColor>(this);

            return(styleBound);
        }
コード例 #29
0
ファイル: SkipList.cs プロジェクト: ikvm/nesper
            internal Submap(SkipList <TK, TV> subDictionary, Bound lower, Bound upper)
            {
                _subDictionary = subDictionary;
                _lower         = lower;
                _upper         = upper;

                if (_subDictionary == null)
                {
                    _lowerTest = k1 => false;
                    _upperTest = k1 => false;
                }
                else
                {
                    var comparer = _subDictionary._comparer ?? new DefaultComparer();
                    _lowerTest = MakeLowerTest(comparer);
                    _upperTest = MakeUpperTest(comparer);
                }
            }
コード例 #30
0
 public override bool IsVisible(PointF point)
 {
     if (Bound.Contains(point))
     {
         Pen p = Pen.Content;
         //线宽过小时不易选中,设置最小宽度为GraphicsTool.WidenWidth
         float minWdith = GraphicsTool.WidenWidth;
         float width    = p.Width;
         if (p.Width < minWdith)
         {
             p.Width = minWdith;
         }
         bool b2 = Path.IsVisible(point);
         p.Width = width;
         return(b2);
     }
     return(false);
 }
コード例 #31
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            // background color, background image, borders
            if (!InitBackgroundImage(stylesheet))
            {
                style.SetBackgroundSettings(this);
            }

            Bound bound = LayoutChildren(stylesheet, styleBound, maxBound);

            _view.ContentSize = new SizeF(bound.ContentWidth, bound.ContentHeight);

            return(styleBound);
        }
コード例 #32
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            // read structure data
            this.NamePointer     = reader.ReadUInt64();
            this.LightAttributes = reader.ReadBlock <ResourceSimpleList64 <LightAttributes> >();
            this.Unknown_C0h     = reader.ReadUInt64();
            this.BoundPointer    = reader.ReadUInt64();

            // read reference data
            this.Name = reader.ReadBlockAt <string_r>(
                this.NamePointer // offset
                );
            this.Bound = reader.ReadBlockAt <Bound>(
                this.BoundPointer // offset
                );
        }
コード例 #33
0
        private string GetPlot()
        {
            var sb          = new StringBuilder();
            var leftCorner  = Bound.BottomLeftCorner;
            var rightCorner = Bound.TopRightCorner;
            var middleX1    = (leftCorner.X1 + rightCorner.X1) / 2;
            ////var h1 = (rightCorner.X1 - leftCorner.X1) / N;
            var h2 = (rightCorner.X2 - leftCorner.X2) / N;

            for (int i = N / 2; i < N; i++)
            {
                var point = new Point2D(middleX1, leftCorner.X2 + i * h2);
                var sol   = Bound.Inside(point) ? Solution(point) : 0;
                var text  = string.Format("{0} {1:F5}", point.X2, sol);
                sb.AppendLine(text);
            }
            return(sb.ToString());
        }
コード例 #34
0
 public bool Contains(T item)
 {
     if (Bound.Contains(item.Position))
     {
         if (m_childs.Length == 0)
         {
             return(ArrayEx.Contains(m_items, m_items_size, item));
         }
         for (int index = 0; index < m_childs.Length; index++)
         {
             if (m_childs[index].Contains(item))
             {
                 return(true);
             }
         }
     }
     return(Parent?.Contains(item) ?? false);
 }
コード例 #35
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            var bound = new Bound(BitBrowserApp.Current.Width, BitBrowserApp.Current.Height);

            base.Apply(stylesheet, bound, bound);

            //background color
            _view.SetBackgroundColor(Android.Graphics.Color.White);

            if (OnLoad != null)
            {
                OnLoad.Execute();
            }

            Frame = new Rectangle(0, 0, bound);

            return(bound);
        }
コード例 #36
0
        internal SubmapDictionary(OrderedDictionary <K, V> subDictionary, Bound lower, Bound upper)
        {
            _subDictionary = subDictionary;
            _lower         = lower;
            _upper         = upper;

            if (_subDictionary == null)
            {
                _lowerTest = k1 => false;
                _upperTest = k1 => false;
            }
            else
            {
                var keyComparer = _subDictionary.KeyComparer ?? new DefaultComparer();
                _lowerTest = MakeLowerTest(keyComparer);
                _upperTest = MakeUpperTest(keyComparer);
            }
        }
コード例 #37
0
 public void checkAndUpdate(Individual individual)
 {
     for (int i = 0; i < individual.placement.Count; i++)
     {
         double   angle       = individual.getRotation()[i];
         NestPath nestPath    = individual.getPlacement()[i];
         Bound    rotateBound = GeometryUtil.rotatePolygon(nestPath, angle);
         if (rotateBound.width < binBounds.width && rotateBound.height < binBounds.height)
         {
             continue;
         }
         else
         {
             double safeAngle = randomAngle(nestPath);
             individual.getRotation()[i] = safeAngle;
         }
     }
 }
コード例 #38
0
ファイル: CustomLayout.cs プロジェクト: Fedorm/core-master
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            // background color, background image, borders
            if (!InitBackgroundImage(stylesheet))
            {
                style.SetBackgroundSettings(this);
            }
            _backgroundColor = _view.BackgroundColor;

            // selected-color
            _selectedColor = style.Color <SelectedColor> (this);

            return(LayoutChildren(stylesheet, styleBound, maxBound));
        }
コード例 #39
0
ファイル: Image.cs プロジェクト: Fedorm/core-master
		public override Bound Apply (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			base.Apply (stylesheet, styleBound, maxBound);

			StyleHelper style = stylesheet.GetHelper<StyleHelper> ();

			// background image
			if (InitImage (stylesheet)) {
				_view.Image = _backgroungImageCache;

				// selected-color
				var selectedColor = style.Color<SelectedColor> (this);
				if (selectedColor != null)
					_selectedImage = GetFilteredImage (_backgroungImageCache, selectedColor);
			}

			return styleBound;
		}
コード例 #40
0
        public async Task <List <AmenityDTO> > getAmenities(Bound region, AmenityType type)
        {
            List <AmenityDTO>    ret = new List <AmenityDTO>();
            OverpassQueryBuilder oqb = new OverpassQueryBuilder(region);
            var sampleQuery          = "";

            //Caso de excessão para pontos de ônibus
            if (type.Equals(AmenityType.bus_station))
            {
                sampleQuery = oqb.busStopsOverpassQuery();
            }
            else
            {
                sampleQuery = oqb.amenityOverpassQuery(type);
            }
            try
            {
                string encodedURL = overpassUrl + HttpUtility.UrlEncode(sampleQuery);
                using (HttpClient client = new HttpClient())
                {
                    var responseString = await client.GetStringAsync(encodedURL);

                    OSMResult osm = JsonConvert.DeserializeObject <OSMResult>(responseString);
                    if (osm.GetNodesAsDictionary != null && osm.GetNodesAsDictionary.Count() > 0)
                    {
                        var nodes = osm.GetNodesAsDictionary;
                        foreach (var node in nodes)
                        {
                            ret.Add(new AmenityDTO()
                            {
                                lat  = (float)node.Value.lat,
                                lng  = (float)node.Value.lon,
                                name = node.Value.tags.ContainsKey("name") ? node.Value.tags["name"] : null
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(ret);
        }
コード例 #41
0
        public bool SetInitBound(Area topo, Point[] points, float thicknessT)
        {
            Bound initBound = new Bound(points, 0, thicknessT, true);
            Bound editBound = new Bound(points, 0, thicknessT, true);
            var   transfrom = new TransformM(initBound);
            var   b1        = Bounds.Add(initBound);
            var   b2        = Bounds.Add(editBound);

            transfrom.IsCreateAreaByData = true;
            transfrom.IsOnAlarmArea      = false;
            transfrom.IsOnLocationArea   = false;
            //TransformMs.Add(transfrom);
            topo.SetTransform(transfrom);
            topo.InitBound = initBound;
            topo.EditBound = editBound;
            var b3 = Areas.Edit(topo);

            return(b1 && b2 && b3);
        }
コード例 #42
0
        public bool SetInitBound(Area topo, Point[] points, BoundInfo boundInfo)
        {
            Bound initBound = new Bound(points, boundInfo);
            Bound editBound = new Bound(points, boundInfo);
            var   transfrom = new TransformM(initBound);
            var   b1        = Bounds.Add(initBound);
            var   b2        = Bounds.Add(editBound);

            transfrom.IsCreateAreaByData = boundInfo.IsCreateAreaByData;
            transfrom.IsOnAlarmArea      = boundInfo.IsOnAlarmArea;
            transfrom.IsOnLocationArea   = boundInfo.IsOnLocationArea;
            //TransformMs.Add(transfrom);
            topo.SetTransform(transfrom);
            topo.InitBound = initBound;
            topo.EditBound = editBound;
            var b3 = Areas.Edit(topo);

            return(b1 && b2 && b3);
        }
コード例 #43
0
        private void SetInitBound(Area topo, Point[] points, float thicknessT, bool isRelative = true,
                                  float bottomHeightT = 0, bool isOnNormalArea = true, bool isOnAlarmArea = false, bool isOnLocationArea = false)
        {
            Bound initBound = new Bound(points, bottomHeightT, thicknessT, isRelative);
            Bound editBound = new Bound(points, bottomHeightT, thicknessT, isRelative);
            var   transfrom = new TransformM(initBound);

            Bounds.Add(initBound);
            Bounds.Add(editBound);
            transfrom.IsCreateAreaByData = isOnNormalArea;
            transfrom.IsOnAlarmArea      = isOnAlarmArea;
            transfrom.IsOnLocationArea   = isOnLocationArea;
            //TransformMs.Add(transfrom);

            topo.SetTransform(transfrom);
            topo.InitBound = initBound;
            topo.EditBound = editBound;
            Areas.Edit(topo);
        }
コード例 #44
0
 public bool Remove(T item)
 {
     if (Bound.Contains(item.Position))
     {
         if (m_childs.Length == 0 && ArrayEx.Remove(m_items, ref m_items_size, item))
         {
             item.Node = null;
             return(true);
         }
         for (int index = 0; index < m_childs.Length; index++)
         {
             if (m_childs[index].Remove(item))
             {
                 return(true);
             }
         }
     }
     return(Parent?.Remove(item) ?? false);
 }
コード例 #45
0
        private void SetInitBound(PhysicalTopology topo, double x1, double y1, double x2, double y2, double thicknessT, bool isRelative = true,
                                  double bottomHeightT = 0, bool isOnNormalArea = true, bool isOnAlarmArea = false, bool isOnLocationArea = false)
        {
            Bound      initBound = new Bound(x1, y1, x2, y2, bottomHeightT, thicknessT, isRelative);
            Bound      editBound = new Bound(x1, y1, x2, y2, bottomHeightT, thicknessT, isRelative);
            TransformM transfrom = new TransformM(initBound);

            Bounds.Add(initBound);
            Bounds.Add(editBound);
            transfrom.IsCreateAreaByData = isOnNormalArea;
            transfrom.IsOnAlarmArea      = isOnAlarmArea;
            transfrom.IsOnLocationArea   = isOnLocationArea;
            TransformMs.Add(transfrom);

            topo.Transfrom = transfrom;
            topo.InitBound = initBound;
            topo.EditBound = editBound;
            PhysicalTopologys.Edit(topo);
        }
コード例 #46
0
        public override void Draw(ExtendedSpriteBatch spriteBatch, float percentage)
        {
            Bound prev = _entity.Previous <PositionData>().Position;
            Bound curr = _entity.Current <PositionData>().Position;

            // some magic constants that center the rendering in the window; the sample doesn't
            // bother to properly setup a coordinate system
            Real scale   = 25;
            Real zoffset = 250;
            Real xoffset = 350;

            int x      = (Interpolate(prev.X, curr.X, percentage) * scale + xoffset).AsInt;
            int z      = (Interpolate(-prev.Z, -curr.Z, percentage) * scale + zoffset).AsInt;
            int radius = (Interpolate(prev.Radius, curr.Radius, percentage) * scale).AsInt;

            Rectangle rectangle = new Rectangle(x - radius, z - radius, 2 * radius, 2 * radius);

            spriteBatch.DrawRectangle(rectangle, Color.BlanchedAlmond);
        }
コード例 #47
0
ファイル: Archetype.cs プロジェクト: indilo53/gta-toolkit
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.Unknown_0h   = reader.ReadSingle();
            this.Unknown_4h   = reader.ReadUInt32();
            this.Unknown_8h   = reader.ReadUInt32();
            this.Unknown_Ch   = reader.ReadUInt32();
            this.Unknown_10h  = reader.ReadUInt32();
            this.Unknown_14h  = reader.ReadUInt32();
            this.NamePointer  = reader.ReadUInt64();
            this.BoundPointer = reader.ReadUInt64();
            this.Unknown_28h  = reader.ReadUInt32();
            this.Unknown_2Ch  = reader.ReadUInt32();
            this.Unknown_30h  = reader.ReadUInt32();
            this.Unknown_34h  = reader.ReadUInt32();
            this.Unknown_38h  = reader.ReadUInt32();
            this.Unknown_3Ch  = reader.ReadUInt32();
            this.Unknown_40h  = reader.ReadSingle();
            this.Unknown_44h  = reader.ReadSingle();
            this.Unknown_48h  = reader.ReadSingle();
            this.Unknown_4Ch  = reader.ReadSingle();
            this.Unknown_50h  = reader.ReadSingle();
            this.Unknown_54h  = reader.ReadSingle();
            this.Unknown_58h  = reader.ReadUInt32();
            this.Unknown_5Ch  = reader.ReadUInt32();
            this.Unknown_60h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_70h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_80h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_90h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_A0h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_B0h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_C0h  = reader.ReadBlock <RAGE_Vector4>();
            this.Unknown_D0h  = reader.ReadBlock <RAGE_Vector4>();

            // read reference data
            this.Name = reader.ReadBlockAt <string_r>(
                this.NamePointer // offset
                );
            this.Bound = reader.ReadBlockAt <Bound>(
                this.BoundPointer // offset
                );
        }
コード例 #48
0
ファイル: TTEntry.cs プロジェクト: torfranz/NetFish
    internal void save(ulong k, ValueT v, Bound b, Depth d, MoveT m, ValueT ev, byte g)
    {
        // Preserve any existing move for the same position
        if ((m != 0) || (k >> 48) != key16)
        {
            move16 = (ushort) m;
        }

        // Don't overwrite more valuable entries
        if ((k >> 48) != key16 || d > depth8 - 2
            /* || g != (genBound8 & 0xFC) // Matching non-zero keys are already refreshed by probe() */
            || b == Bound.BOUND_EXACT)
        {
            key16 = (ushort) (k >> 48);
            value16 = (short) v;
            eval16 = (short) ev;
            genBound8 = (byte) (g | (int) b);
            depth8 = d;
        }
    }
コード例 #49
0
        public BoundInfo(Bound bound) : this()
        {
            if (bound != null)
            {
                Thickness  = bound.MaxZ - bound.MinZ;
                IsRelative = bound.IsRelative;

                if (bound.Points != null)
                {
                    foreach (Point point in bound.Points)
                    {
                        Points.Add(new PointInfo(point));
                    }
                }
                //else
                //{
                //    Points.Add(new PointInfo());
                //}
            }
        }
コード例 #50
0
ファイル: GoodShape.cs プロジェクト: goodmaker/gooddrawer
        public static GoodShape GetShape(string  metadata, Canvas parent)
        {
            string[] firstData = metadata.Split(new char[]{'[','(',']',')'}, StringSplitOptions.RemoveEmptyEntries);
            if (firstData.Length != 3)
                throw new ArgumentException();
            Bound b = new Bound('('+firstData[1]+')', parent);
            string[] data =(firstData[0]+firstData[2]).Split(new char[] { ';', ':', '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
            GoodShape gs = null;

            if(data[0] ==  "Star")
            {
                gs = new GoodStar(Convert.ToInt32(data[8]), Convert.ToDouble(data[10]), b);

               // ColorConverter cc = new ColorConverter();

            }
            else if(data[0] == "Polygon")
            {
                gs = new GoodPolygon(Convert.ToInt32(data[8]), b);
            }
            else if (data[0] == "Rectangle")
            {
                gs = new GoodRectangle(b, Convert.ToDouble(data[8]), Convert.ToDouble(data[10]));
            }
            else if( data[0] == "Ellipse")
            {
                gs = new GoodEllipse(b);
            }
            if(gs != null)
            {
                gs.Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString(data[2]));
                gs.BorderPen.Brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(data[4]));
                gs.BorderPen.Thickness = Convert.ToDouble(data[6]);
            }
            return gs;
        }
コード例 #51
0
        /// <summary>
        /// Inserts a new bound into an axis list.  The list is assumed to be
        /// sorted, so the method uses binary insertion for speed.
        /// </summary>
        /// <param name="axis">The axis list to insert the Bound into</param>
        /// <param name="bound">The Bound to insert</param>
        /// <returns>The index where the bound was inserted</returns>
        private int InsertBoundIntoAxis(List<Bound> axis, Bound bound)
        {
            // Use binary search for fast O(log(n)) indentification
            // of appropriate index for our bound
            int index = axis.BinarySearch(bound);
            if (index < 0)
            {
                // If the index returned by binary search is negative,
                // then our current bound value does not exist within the
                // axis (most common case).  The bitwise compliement (~) of
                // that index value indicates the index of the first element
                // in the axis list *larger* than our bound, and therefore
                // the appropriate place for our item
                index = ~index;
                axis.Insert(index, bound);
            }
            else
            {
                // If the index returned by binary search is positive, then
                // we have another bound with the *exact same value*.  We'll
                // go ahead and insert at that position.
                axis.Insert(index, bound);
            }

            return index;
        }
コード例 #52
0
        /// <summary>
        /// Queries a rectangular region and retuns game object ids for
        /// all game objects within that region
        /// </summary>
        /// <param name="bounds">A bounding rectangle for the region of interest</param>
        /// <returns>An array of game object ids</returns>
        public uint[] QueryRegion(Rectangle bounds)
        {
            HashSet<uint> matches = new HashSet<uint>();

            // Find the minimal index in the horizontal axis list using binary search
            Bound left = new Bound(null, bounds.Left, BoundType.Min);

            int minHorizontalIndex = horizontalAxis.BinarySearch(left);
            if (minHorizontalIndex < 0)
            {
                // If the index returned by binary search is negative,
                // then our current bound value does not exist within the
                // axis (most common case).  The bitwise compliement (~) of
                // that index value indicates the index of the first element
                // in the axis list *larger* than our bound, and therefore
                // the first potentailly intersecting item
                minHorizontalIndex = ~minHorizontalIndex;
            }

            Bound right = new Bound(null, bounds.Left, BoundType.Max);
            int maxHorizontalIndex = horizontalAxis.BinarySearch(right);
            if (maxHorizontalIndex < 0) maxHorizontalIndex = ~maxHorizontalIndex;

            for (int i = minHorizontalIndex; i < maxHorizontalIndex; i++)
            {
                matches.Add(horizontalAxis[i].Box.GameObjectID);
            }

            Bound top = new Bound(null, bounds.Left, BoundType.Min);
            int minVerticalIndex = verticalAxis.BinarySearch(top);
            if (minVerticalIndex < 0) minVerticalIndex = ~minVerticalIndex;

            Bound bottom = new Bound(null, bounds.Bottom, BoundType.Max);
            int maxVerticalIndex = verticalAxis.BinarySearch(bottom);
            if (maxVerticalIndex < 0) maxVerticalIndex = ~maxVerticalIndex;

            for (int i = minVerticalIndex; i < maxVerticalIndex; i++)
            {
                matches.Add(verticalAxis[i].Box.GameObjectID);
            }

            return matches.ToArray();
        }
コード例 #53
0
 private void InitParameters()
 {
     shift = 20;
     trackBarColor = new color();
     boundOfValuesOfMatrix = new Bound();
     boundOfValuesOfBlocks = new Bound();
 }
コード例 #54
0
 private void canvas_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Delete)
     {
         if (CurrentShape != null)
         {
             CurrentShape.Bound.hide();
             CurrentShape.removeBound();
             drawingSurface.DeleteVisual(CurrentShape);
             currentShape = null;
             bo = null;
             gShapes.Remove(CurrentShape);
         }
     }
 }
コード例 #55
0
 private void Shape_Checked(object sender, RoutedEventArgs e)
 {
     if (sender == Rectangle)
         sim.setObjects(typeof(GoodRectangle), ShapeInfo);
     if (sender == Star)
         sim.setObjects(typeof(GoodStar), ShapeInfo);
     if (sender == Ellipse)
         sim.setObjects(typeof(GoodEllipse), ShapeInfo);
     if (sender == Polygon)
         sim.setObjects(typeof(GoodPolygon), ShapeInfo);
     if(currentShape != null)
     currentShape = null;
     if (bo != null)
     {
         bo.hide();
         bo = null;
     }
 }
コード例 #56
0
 private void setActive(GoodShape shape)
 {
     if(shape != null)
     {
         if (bo != null) bo.hide();
         bo = shape.Bound;
         currentShape = shape;
         sim.setObjects(shape.GetType(), ShapeInfo);
         bo.show();
         bo.Focus();
     }
 }
コード例 #57
0
        void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point pos = e.GetPosition(drawingSurface);
            if (bo != null)
                if (!bo.contains(pos))
                {
                    bo.hide();
                    bo = null;
                    return;
                }
            if (bo == null)
            {
                bo = new Bound(canvas, pos);
                bo.LostFocus += bo_LostFocus;
                bo.Focus();
                if (Star.IsChecked == true)
                {

                    currentShape = new GoodStar(5, 0.4, bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Polygon.IsChecked == true)
                {

                    currentShape = new GoodPolygon(7, bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if(Ellipse.IsChecked == true)
                {
                    currentShape = new GoodEllipse(bo);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), BorderThickness.Value);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Rectangle.IsChecked == true)
                {
                    currentShape = new GoodRectangle(bo, 0, 0);
                    currentShape.Color = new SolidColorBrush(ShapeColor.SelectedColor);
                    currentShape.BorderPen = new Pen(new SolidColorBrush(StrokeColor.SelectedColor), 1);
                    drawingSurface.AddVisual(currentShape);
                    gShapes.Add(currentShape);
                }
                if (Picker.IsChecked == true)
                {

                }
            }
        }
コード例 #58
0
ファイル: GoodShape.cs プロジェクト: goodmaker/gooddrawer
 public void removeBound()
 {
     bound = null;
 }
コード例 #59
0
ファイル: TT.cs プロジェクト: torfranz/Portfish
        /// TranspositionTable::store() writes a new entry containing position key and
        /// valuable information of current position. The lowest order bits of position
        /// key are used to decide on which cluster the position will be placed.
        /// When a new entry is written and there are no empty entries available in cluster,
        /// it replaces the least valuable of entries. A TTEntry t1 is considered to be
        /// more valuable than a TTEntry t2 if t1 is from the current search and t2 is from
        /// a previous search, or if the depth of t1 is bigger than the depth of t2.
        internal static void store(ulong key, int v, Bound t, int d, int m, Value statV, Value kingD)
        {
            var key32 = (uint)(key >> 32); // Use the high 32 bits as key inside the cluster
            uint ttePos = 0;
            uint replacePos = 0;
            ttePos = replacePos = (((uint)key) & sizeMask) << 2;

            for (uint i = 0; i < Constants.ClusterSize; i++)
            {
                var tte = table[ttePos];

                if ((tte.key == 0) || tte.key == key32 ) // Empty or overwrite old
                {
                    // Preserve any existing ttMove
                    if (m == MoveC.MOVE_NONE)
                    {
                        m = tte.move16;
                    }

                    table[ttePos].save(key32 , v, t, d, m, generation, statV, kingD);
                    return;
                }

                // Implement replace strategy
                //if ((entries[replacePos].generation8 == generation ? 2 : 0) + (tte.generation8 == generation || tte.bound == 3/*Bound.BOUND_EXACT*/ ? -2 : 0) + (tte.depth16 < entries[replacePos].depth16 ? 1 : 0) > 0)
                //{
                //    replacePos = ttePos;
                //}

                if (table[replacePos].generation8 == generation)
                {
                    // +2
                    if (tte.generation8 == generation || tte.bound == 3 /*Bound.BOUND_EXACT*/)
                    {
                        // 0
                        if (tte.depth16 < table[replacePos].depth16)
                        {
                            // +1
                            replacePos = ttePos;
                        }
                    }
                    else
                    {
                        // +2
                        replacePos = ttePos;
                    }
                }
                else
                {
                    // 0
                    if ((!(tte.generation8 == generation || tte.bound == 3 /*Bound.BOUND_EXACT*/))
                        && (tte.depth16 < table[replacePos].depth16))
                    {
                        // +1
                        replacePos = ttePos;
                    }
                }

                ttePos++;
            }
            table[replacePos].save(key32 , v, t, d, m, generation, statV, kingD);
        }
コード例 #60
0
        /// <summary>
        /// Queries a rectangular region and retuns game object ids for
        /// all game objects within that region
        /// </summary>
        /// <param name="bounds">A bounding rectangle for the region of interest</param>
        /// <returns>An array of game object ids</returns>
        public uint[] QueryRegion(Rectangle bounds)
        {
            HashSet<uint> matches = new HashSet<uint>();

            // Find the maximal index for the bounding region in the vertical
            // axis list
            Bound top = new Bound(null, bounds.Top, BoundType.Min);
            int minVerticalIndex = verticalAxis.BinarySearch(top);
            if (minVerticalIndex < 0) minVerticalIndex = ~minVerticalIndex;

            // Find the minimal index for the bounding region in the vertical
            // axis list
            Bound bottom = new Bound(null, bounds.Bottom, BoundType.Max);
            int maxVerticalIndex = verticalAxis.BinarySearch(bottom);
            if (maxVerticalIndex < 0) maxVerticalIndex = ~maxVerticalIndex;

            // Collect all game object ids between the minimal and maximal
            // indices
            for (int i = minVerticalIndex; i < maxVerticalIndex; i++)
            {
                matches.Add(verticalAxis[i].Box.GameObjectID);
            }

            return matches.ToArray();
        }