C#C
C#3y ago
popcorn

✅ Why is my bfs so slow?

        private const int BOARD_SIZE = 8;
        private static readonly List<Point> KING_MOVES = new List<Point>() { new Point(-1, 0), new Point(-1, 1), new Point(0, 1), new Point(1, 1), new Point(1, 0), new Point(1, -1), new Point(0, -1), new Point(-1, -1) };

        class Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public Point(Point p)
            {
                this.x = p.x;
                this.y = p.y;
            }

            public override bool Equals(object? obj)
            {
                Point p = obj as Point;
                return this.x == p.x && this.y == p.y;
            }

            public void Add(Point p)
            {
                this.x = this.x + p.x;
                this.y = this.y + p.y;
            }
        }

        static bool PointInBounds(Point p)
        {
            if (p.x < 1 || p.y < 1)
            {
                return false;
            }

            if (p.x > BOARD_SIZE || p.y > BOARD_SIZE)
            {
                return false;
            }
            return true;
        }

Here are my "support" classes and method
Was this page helpful?