Example #1
0
        private void acc(Node n)
        {
            var epsilon = new RealExtensions.Epsilon(1E-30);

            if (speed >= 1.0)
            {
                n.accSpeed = speed - Math.Abs(speed) + n.parent.accSpeed;
                if (n.parent.accSpeed.LE(1.0, epsilon))
                {
                    n.accSpeed -= 1.0;
                }
            }
            else
            {
                n.accSpeed = n.parent.accSpeed + speed;
                if (n.parent.accSpeed.LE(1.0, epsilon))
                {
                    n.accSpeed -= 1.0;
                }
            }
        }
Example #2
0
        private List <Node> getAdjacent(Node n, Node[][][] matrix)
        {
            List <Node> adj  = new List <Node> ();
            int         time = 0;

            var epsilon = new RealExtensions.Epsilon(1E-30);

            if (speed >= 1.0)
            {
                time = (int)Math.Floor(speed);
            }

            if (n.accSpeed.LE(1.0, epsilon))
            {
                time++;
            }

            if (n.t + time >= matrix.Length)
            {
                return(adj);
            }
            for (int xx = n.x - 3; xx <= n.x + 3; xx++)
            {
                for (int yy = n.y - 3; yy <= n.y + 3; yy++)
                {
                    if (xx <= n.x + 3 && xx >= 0 && xx < matrix.Length && yy <= n.y + 3 && yy >= 0 && yy < matrix [0].Length)
                    {
                        Node c = matrix [n.t + time] [xx] [yy];
                        //if (!((Cell)c.cell).blocked) {
                        if ((c.cell).IsWalkable())
                        {
                            adj.Add(c);
                        }
                    }
                }
            }
            //adj.Remove (n);
            return(adj);
        }